xref: /llvm-project/llvm/test/Transforms/GVNHoist/pr38807.ll (revision 055fb7795aa219a3d274d280ec9129784f169f56)
1; RUN: opt < %s -passes='early-cse<memssa>,gvn-hoist' -earlycse-debug-hash -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(ptr %arg) {
12bb0:
13  %call.idx.val.i = load i32, ptr %arg
14  br label %bb1
15
16;CHECK: bb1:
17;CHECK:   %call264 = call zeroext i1 @bar
18;CHECK:   store i32 %call.idx.val.i, ptr %arg
19;CHECK:   %0 = getelementptr inbounds %S, ptr %arg, i64 0, i32 0, i32 1
20;CHECK:   store i64 undef, ptr %0
21;CHECK:   br i1 %call264, label %bb2, label %bb3
22
23bb1:
24  %call264 = call zeroext i1 @bar()
25  br i1 %call264, label %bb2, label %bb3
26
27;CHECK:     bb2:
28;CHECK-NOT:   store i32 %call.idx.val.i, ptr %arg
29;CHECK-NOT:   store i64 undef, ptr %{.*}
30
31bb2:
32  store i32 %call.idx.val.i, ptr %arg
33  %0 = getelementptr inbounds %S, ptr %arg, i64 0, i32 0, i32 1
34  store i64 undef, ptr %0
35  ret void
36
37;CHECK:     bb3:
38;CHECK-NOT:   store i32 %call.idx.val.i, ptr %arg
39;CHECK-NOT:   store i64 undef, ptr %{.*}
40
41bb3:
42  store i32 %call.idx.val.i, ptr %arg
43  %1 = getelementptr inbounds %S, ptr %arg, i64 0, i32 0, i32 1
44  store i64 undef, ptr %1
45  ret void
46}
47
48declare zeroext i1 @bar()
49