• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -S -instcombine %s -o - | FileCheck %s
3
4; All the "useless" instructions should be removed and we shouldn't crash.
5
6target datalayout = "p:16:16"
7
8%i64_t = type i64
9
10@a = external global i16
11@b = external global i16*
12
13define void @f(i1 %cond) {
14; CHECK-LABEL: @f(
15; CHECK-NEXT:  bb0:
16; CHECK-NEXT:    [[T12:%.*]] = alloca [2 x i32], align 8
17; CHECK-NEXT:    [[T12_SUB:%.*]] = getelementptr inbounds [2 x i32], [2 x i32]* [[T12]], i16 0, i16 0
18; CHECK-NEXT:    br i1 [[COND:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
19; CHECK:       bb1:
20; CHECK-NEXT:    unreachable
21; CHECK:       bb2:
22; CHECK-NEXT:    [[T9:%.*]] = load i16*, i16** @b, align 2
23; CHECK-NEXT:    store i16 0, i16* [[T9]], align 2
24; CHECK-NEXT:    [[T10:%.*]] = load i32, i32* [[T12_SUB]], align 8
25; CHECK-NEXT:    [[T11:%.*]] = add i32 [[T10]], -1
26; CHECK-NEXT:    store i32 [[T11]], i32* [[T12_SUB]], align 8
27; CHECK-NEXT:    ret void
28;
29bb0:
30  %t1 = alloca %i64_t
31  %t2 = bitcast %i64_t* %t1 to i32*
32  %useless3 = bitcast %i64_t* %t1 to i16*
33  %useless4 = getelementptr inbounds i16, i16* %useless3, i16 undef
34  %useless5 = bitcast i16* %useless4 to i32*
35  br i1 %cond, label %bb1, label %bb2
36
37bb1:                                              ; preds = %bb0
38  %useless6 = insertvalue [1 x i32*] undef, i32* %t2, 0
39  %useless7 = insertvalue [1 x i32*] %useless6, i32* null, 0
40  %t8 = ptrtoint i32* %t2 to i16
41  store i16 %t8, i16* @a
42  unreachable
43
44bb2:                                              ; preds = %bb0
45  %t9 = load i16*, i16** @b
46  store i16 0, i16* %t9
47  %t10 = load i32, i32* %t2
48  %t11 = sub i32 %t10, 1
49  store i32 %t11, i32* %t2
50  ret void
51}
52