1 ; RUN: opt -gvn-sink -S < %s | FileCheck %s
2 ; RUN: opt -passes=gvn-sink -S < %s | FileCheck %s
4 %struct = type {i32, i32}
5 %struct2 = type { [ 2 x i32], i32 }
7 ; Struct indices cannot be variant.
10 ; CHECK: getelementptr
11 ; CHECK: getelementptr
14 br i1 undef, label %bb2, label %bb1
17 %tmp = getelementptr inbounds %struct, %struct* null, i64 0, i32 1
21 %tmp3 = getelementptr inbounds %struct, %struct* null, i64 0, i32 0
24 bb4: ; preds = %bb2, %bb1
25 %tmp5 = phi i32 [ 1, %bb1 ], [ 0, %bb2 ]
29 ; Struct indices cannot be variant.
32 ; CHECK: getelementptr
33 ; CHECK: getelementptr
36 br i1 undef, label %bb2, label %bb1
39 %tmp = getelementptr inbounds %struct2, %struct2* null, i64 0, i32 0, i32 1
43 %tmp3 = getelementptr inbounds %struct2, %struct2* null, i64 0, i32 0, i32 0
46 bb4: ; preds = %bb2, %bb1
47 %tmp5 = phi i32 [ 1, %bb1 ], [ 0, %bb2 ]
52 ; ... but the first parameter to a GEP can.
55 ; CHECK: getelementptr
56 ; CHECK-NOT: getelementptr
59 br i1 undef, label %bb2, label %bb1
62 %tmp = getelementptr inbounds %struct, %struct* null, i32 0, i32 0
66 %tmp3 = getelementptr inbounds %struct, %struct* null, i32 1, i32 0
69 bb4: ; preds = %bb2, %bb1
70 %tmp5 = phi i32 [ 0, %bb1 ], [ 1, %bb2 ]