1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals --version 2
2 ; RUN: opt -S -passes=gvn-hoist < %s | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
6 define void @test1(i1 %b, ptr %x) {
7 ; CHECK-LABEL: define void @test1
8 ; CHECK-SAME: (i1 [[B:%.*]], ptr [[X:%.*]]) {
10 ; CHECK-NEXT: store i32 2, ptr [[X]], align 4, !tbaa [[TBAA0:![0-9]+]]
11 ; CHECK-NEXT: br i1 [[B]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
13 ; CHECK-NEXT: br label [[IF_END:%.*]]
15 ; CHECK-NEXT: br label [[IF_END]]
17 ; CHECK-NEXT: ret void
20 br i1 %b, label %if.then, label %if.else
22 if.then: ; preds = %entry
23 store i32 2, ptr %x, align 4, !tbaa !1
26 if.else: ; preds = %entry
27 store i32 2, ptr %x, align 4, !tbaa !5
30 if.end: ; preds = %if.else, %if.then
34 define void @test2(i1 %b, ptr %x) {
35 ; CHECK-LABEL: define void @test2
36 ; CHECK-SAME: (i1 [[B:%.*]], ptr [[X:%.*]]) {
38 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 1
39 ; CHECK-NEXT: store i32 2, ptr [[TMP0]], align 4, !tbaa [[TBAA0]]
40 ; CHECK-NEXT: br i1 [[B]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
42 ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 1
43 ; CHECK-NEXT: br label [[IF_END:%.*]]
45 ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 1
46 ; CHECK-NEXT: br label [[IF_END]]
48 ; CHECK-NEXT: ret void
51 br i1 %b, label %if.then, label %if.else
53 if.then: ; preds = %entry
54 %gep1 = getelementptr inbounds i32, ptr %x, i64 1
55 store i32 2, ptr %gep1, align 4, !tbaa !1
58 if.else: ; preds = %entry
59 %gep2 = getelementptr inbounds i32, ptr %x, i64 1
60 store i32 2, ptr %gep2, align 4, !tbaa !5
63 if.end: ; preds = %if.else, %if.then
67 define void @test3(i1 %b, ptr %x) {
68 ; CHECK-LABEL: define void @test3
69 ; CHECK-SAME: (i1 [[B:%.*]], ptr [[X:%.*]]) {
71 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr i32, ptr [[X]], i64 1
72 ; CHECK-NEXT: store i32 2, ptr [[TMP0]], align 4, !tbaa [[TBAA0]]
73 ; CHECK-NEXT: br i1 [[B]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
75 ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 1
76 ; CHECK-NEXT: br label [[IF_END:%.*]]
78 ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr i32, ptr [[X]], i64 1
79 ; CHECK-NEXT: br label [[IF_END]]
81 ; CHECK-NEXT: ret void
84 br i1 %b, label %if.then, label %if.else
86 if.then: ; preds = %entry
87 %gep1 = getelementptr inbounds i32, ptr %x, i64 1
88 store i32 2, ptr %gep1, align 4, !tbaa !1
91 if.else: ; preds = %entry
92 %gep2 = getelementptr i32, ptr %x, i64 1
93 store i32 2, ptr %gep2, align 4, !tbaa !5
96 if.end: ; preds = %if.else, %if.then
100 define i32 @test4(i1 %b, ptr %y) {
101 ; CHECK-LABEL: define i32 @test4
102 ; CHECK-SAME: (i1 [[B:%.*]], ptr [[Y:%.*]]) {
104 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[Y]], align 4, !range [[RNG3:![0-9]+]]
105 ; CHECK-NEXT: br i1 [[B]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
107 ; CHECK-NEXT: br label [[RETURN:%.*]]
109 ; CHECK-NEXT: br label [[RETURN]]
111 ; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i32 [ [[TMP0]], [[IF_THEN]] ], [ [[TMP0]], [[IF_END]] ]
112 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
115 br i1 %b, label %if.then, label %if.end
117 if.then: ; preds = %entry
118 %0 = load i32, ptr %y, align 4, !range !7
121 if.end: ; preds = %entry
122 %1 = load i32, ptr %y, align 4, !range !8
125 return: ; preds = %if.end, %if.then
126 %retval.0 = phi i32 [ %0, %if.then ], [ %1, %if.end ]
130 define ptr @test5(i1 %b, ptr %y) {
131 ; CHECK-LABEL: define ptr @test5
132 ; CHECK-SAME: (i1 [[B:%.*]], ptr [[Y:%.*]]) {
134 ; CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[Y]], align 4
135 ; CHECK-NEXT: br i1 [[B]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
137 ; CHECK-NEXT: br label [[RETURN:%.*]]
139 ; CHECK-NEXT: br label [[RETURN]]
141 ; CHECK-NEXT: [[RETVAL_0:%.*]] = phi ptr [ [[TMP0]], [[IF_THEN]] ], [ [[TMP0]], [[IF_END]] ]
142 ; CHECK-NEXT: ret ptr [[RETVAL_0]]
145 br i1 %b, label %if.then, label %if.end
147 if.then: ; preds = %entry
148 %0 = load ptr, ptr %y, align 4, !nonnull !9
151 if.end: ; preds = %entry
152 %1 = load ptr, ptr %y, align 4
155 return: ; preds = %if.end, %if.then
156 %retval.0 = phi ptr [ %0, %if.then ], [ %1, %if.end ]
160 !1 = !{!2, !2, i64 0}
161 !2 = !{!"int", !3, i64 0}
162 !3 = !{!"omnipotent char", !4, i64 0}
163 !4 = !{!"Simple C++ TBAA"}
164 !5 = !{!6, !6, i64 0}
165 !6 = !{!"_ZTS1e", !3, i64 0}
170 ; CHECK: [[TBAA0]] = !{!1, !1, i64 0}
171 ; CHECK: [[META1:![0-9]+]] = !{!"omnipotent char", !2, i64 0}
172 ; CHECK: [[META2:![0-9]+]] = !{!"Simple C++ TBAA"}
173 ; CHECK: [[RNG3]] = !{i32 0, i32 2, i32 3, i32 4}