1; RUN: opt < %s -early-cse-memssa -earlycse-debug-hash -gvn-hoist -S | FileCheck %s
2
3; Make sure opt doesn't crash. On top of that, the instructions
4; of the side blocks should be hoisted to the entry block.
5
6%s = type { i32, i64 }
7%S = type { %s, i32 }
8
9;CHECK-LABEL: @foo
10
11define void @foo(i32* %arg) {
12bb0:
13  %0 = bitcast i32* %arg to %S*
14  %call.idx.i = getelementptr %S, %S* %0, i64 0, i32 0, i32 0
15  %call.idx.val.i = load i32, i32* %call.idx.i
16  br label %bb1
17
18;CHECK: bb1:
19;CHECK:   %call264 = call zeroext i1 @bar
20;CHECK:   store i32 %call.idx.val.i, i32* %call.idx.i
21;CHECK:   %1 = getelementptr inbounds %S, %S* %0, i64 0, i32 0, i32 1
22;CHECK:   store i64 undef, i64* %1
23;CHECK:   br i1 %call264, label %bb2, label %bb3
24
25bb1:
26  %call264 = call zeroext i1 @bar()
27  br i1 %call264, label %bb2, label %bb3
28
29;CHECK:     bb2:
30;CHECK-NOT:   store i32 %call.idx.val.i, i32* %call.idx.i
31;CHECK-NOT:   store i64 undef, i64* %{.*}
32
33bb2:
34  store i32 %call.idx.val.i, i32* %call.idx.i
35  %1 = getelementptr inbounds %S, %S* %0, i64 0, i32 0, i32 1
36  store i64 undef, i64* %1
37  ret void
38
39;CHECK:     bb3:
40;CHECK-NOT:   store i32 %call.idx.val.i, i32* %call.idx.i
41;CHECK-NOT:   store i64 undef, i64* %{.*}
42
43bb3:
44  store i32 %call.idx.val.i, i32* %call.idx.i
45  %2 = getelementptr inbounds %S, %S* %0, i64 0, i32 0, i32 1
46  store i64 undef, i64* %2
47  ret void
48}
49
50declare zeroext i1 @bar()
51