1 ; RUN: opt -S -gvn-hoist < %s | FileCheck %s
2 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
3 target triple = "x86_64-unknown-linux-gnu"
5 define void @test1(i1 %b, i32* %x) {
7 br i1 %b, label %if.then, label %if.else
9 if.then: ; preds = %entry
10 store i32 2, i32* %x, align 4, !tbaa !1
13 if.else: ; preds = %entry
14 store i32 2, i32* %x, align 4, !tbaa !5
17 if.end: ; preds = %if.else, %if.then
20 ; CHECK-LABEL: define void @test1(
21 ; CHECK: store i32 2, i32* %x, align 4
22 ; CHECK-NEXT: br i1 %b
24 define void @test2(i1 %b, i32* %x) {
26 br i1 %b, label %if.then, label %if.else
28 if.then: ; preds = %entry
29 %gep1 = getelementptr inbounds i32, i32* %x, i64 1
30 store i32 2, i32* %gep1, align 4, !tbaa !1
33 if.else: ; preds = %entry
34 %gep2 = getelementptr inbounds i32, i32* %x, i64 1
35 store i32 2, i32* %gep2, align 4, !tbaa !5
38 if.end: ; preds = %if.else, %if.then
41 ; CHECK-LABEL: define void @test2(
42 ; CHECK: %[[gep:.*]] = getelementptr inbounds i32, i32* %x, i64 1
43 ; CHECK: store i32 2, i32* %[[gep]], align 4
44 ; CHECK-NEXT: br i1 %b
46 define void @test3(i1 %b, i32* %x) {
48 br i1 %b, label %if.then, label %if.else
50 if.then: ; preds = %entry
51 %gep1 = getelementptr inbounds i32, i32* %x, i64 1
52 store i32 2, i32* %gep1, align 4, !tbaa !1
55 if.else: ; preds = %entry
56 %gep2 = getelementptr i32, i32* %x, i64 1
57 store i32 2, i32* %gep2, align 4, !tbaa !5
60 if.end: ; preds = %if.else, %if.then
63 ; CHECK-LABEL: define void @test3(
64 ; CHECK: %[[gep:.*]] = getelementptr i32, i32* %x, i64 1
65 ; CHECK: store i32 2, i32* %[[gep]], align 4
66 ; CHECK-NEXT: br i1 %b
69 !2 = !{!"int", !3, i64 0}
70 !3 = !{!"omnipotent char", !4, i64 0}
71 !4 = !{!"Simple C++ TBAA"}
73 !6 = !{!"_ZTS1e", !3, i64 0}
75 define i32 @test4(i1 %b, i32* %y) {
77 br i1 %b, label %if.then, label %if.end
79 if.then: ; preds = %entry
80 %0 = load i32, i32* %y, align 4, !range !7
83 if.end: ; preds = %entry
84 %1 = load i32, i32* %y, align 4, !range !8
87 return: ; preds = %if.end, %if.then
88 %retval.0 = phi i32 [ %0, %if.then ], [ %1, %if.end ]
91 ; CHECK-LABEL: define i32 @test4(
92 ; CHECK: %[[load:.*]] = load i32, i32* %y, align 4, !range ![[range_md:.*]]
93 ; CHECK: %[[phi:.*]] = phi i32 [ %[[load]], %{{.*}} ], [ %[[load]], %{{.*}} ]
94 ; CHECK: ret i32 %[[phi]]
96 define i32* @test5(i1 %b, i32** %y) {
98 br i1 %b, label %if.then, label %if.end
100 if.then: ; preds = %entry
101 %0 = load i32*, i32** %y, align 4, !nonnull !9
104 if.end: ; preds = %entry
105 %1 = load i32*, i32** %y, align 4
108 return: ; preds = %if.end, %if.then
109 %retval.0 = phi i32* [ %0, %if.then ], [ %1, %if.end ]
112 ; CHECK-LABEL: define i32* @test5(
113 ; CHECK: %[[load:.*]] = load i32*, i32** %y, align 4
114 ; CHECK-NOT: !nonnull
115 ; CHECK: %[[phi:.*]] = phi i32* [ %[[load]], %{{.*}} ], [ %[[load]], %{{.*}} ]
116 ; CHECK: ret i32* %[[phi]]
121 ; CHECK: ![[range_md]] = !{i32 0, i32 2, i32 3, i32 4}