1 ; RUN: opt -passes=gvn-sink -S < %s | FileCheck %s
3 %struct = type {i32, i32, i32}
4 %struct2 = type { [ 2 x i32], i32 }
6 ; Struct indices cannot be variant.
8 ; CHECK-LABEL: @f(i1 %arg) {
10 ; CHECK: getelementptr
11 define void @f(i1 %arg) {
13 br i1 %arg, label %bb2, label %bb1
16 %tmp = getelementptr inbounds %struct, ptr null, i64 0, i32 1
20 %tmp3 = getelementptr inbounds %struct, ptr null, i64 0, i32 2
23 bb4: ; preds = %bb2, %bb1
24 %tmp5 = phi i32 [ 1, %bb1 ], [ 2, %bb2 ]
28 ; Struct indices cannot be variant.
30 ; CHECK-LABEL: @g(i1 %arg) {
31 ; CHECK: getelementptr
32 ; CHECK: getelementptr
33 define void @g(i1 %arg) {
35 br i1 %arg, label %bb2, label %bb1
38 %tmp = getelementptr inbounds %struct2, ptr null, i64 0, i32 0, i32 1
42 %tmp3 = getelementptr inbounds %struct2, ptr null, i64 0, i32 0, i32 2
45 bb4: ; preds = %bb2, %bb1
46 %tmp5 = phi i32 [ 1, %bb1 ], [ 2, %bb2 ]
51 ; ... but the first parameter to a GEP can.
53 ; CHECK-LABEL: @h(i1 %arg) {
54 ; CHECK: getelementptr
55 ; CHECK-NOT: getelementptr
56 define void @h(i1 %arg) {
58 br i1 %arg, label %bb2, label %bb1
61 %tmp = getelementptr inbounds %struct, ptr null, i32 1, i32 0
65 %tmp3 = getelementptr inbounds %struct, ptr null, i32 2, i32 0
68 bb4: ; preds = %bb2, %bb1
69 %tmp5 = phi i32 [ 1, %bb1 ], [ 2, %bb2 ]