1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -basic-aa -dse -S | FileCheck %s
4 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
7 define void @test2(i32* noalias %P) {
9 ; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
11 ; CHECK-NEXT: br label [[BB3:%.*]]
13 ; CHECK-NEXT: br label [[BB3]]
15 ; CHECK-NEXT: store i32 0, i32* [[P:%.*]], align 4
16 ; CHECK-NEXT: ret void
19 br i1 true, label %bb1, label %bb2
29 define void @test3(i32* noalias %P) {
30 ; CHECK-LABEL: @test3(
31 ; CHECK-NEXT: store i32 0, i32* [[P:%.*]], align 4
32 ; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
34 ; CHECK-NEXT: br label [[BB3:%.*]]
36 ; CHECK-NEXT: store i32 1, i32* [[P]], align 4
37 ; CHECK-NEXT: br label [[BB3]]
39 ; CHECK-NEXT: ret void
42 br i1 true, label %bb1, label %bb2
53 define void @test7(i32* noalias %P, i32* noalias %Q) {
54 ; CHECK-LABEL: @test7(
55 ; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
57 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* [[P:%.*]], align 4
58 ; CHECK-NEXT: br label [[BB3:%.*]]
60 ; CHECK-NEXT: br label [[BB3]]
62 ; CHECK-NEXT: store i32 0, i32* [[Q:%.*]], align 4
63 ; CHECK-NEXT: store i32 0, i32* [[P]], align 4
64 ; CHECK-NEXT: ret void
67 br i1 true, label %bb1, label %bb2
79 define i32 @test22(i32* %P, i32* noalias %Q, i32* %R) {
80 ; CHECK-LABEL: @test22(
81 ; CHECK-NEXT: store i32 2, i32* [[P:%.*]], align 4
82 ; CHECK-NEXT: store i32 3, i32* [[Q:%.*]], align 4
83 ; CHECK-NEXT: [[L:%.*]] = load i32, i32* [[R:%.*]], align 4
84 ; CHECK-NEXT: ret i32 [[L]]
89 %l = load i32, i32* %R
93 define void @test9(i32* noalias %P) {
94 ; CHECK-LABEL: @test9(
95 ; CHECK-NEXT: store i32 0, i32* [[P:%.*]], align 4
96 ; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
98 ; CHECK-NEXT: br label [[BB3:%.*]]
100 ; CHECK-NEXT: ret void
102 ; CHECK-NEXT: store i32 1, i32* [[P]], align 4
103 ; CHECK-NEXT: ret void
106 br i1 true, label %bb1, label %bb2
116 ; We cannot eliminate `store i32 0, i32* %P`, as it is read by the later load.
117 ; Make sure that we check the uses of `store i32 1, i32* %P.1 which does not
118 ; alias %P. Note that uses point to the *first* def that may alias.
119 define void @overlapping_read(i32* %P) {
120 ; CHECK-LABEL: @overlapping_read(
121 ; CHECK-NEXT: store i32 0, i32* [[P:%.*]], align 4
122 ; CHECK-NEXT: [[P_1:%.*]] = getelementptr i32, i32* [[P]], i32 1
123 ; CHECK-NEXT: store i32 1, i32* [[P_1]], align 4
124 ; CHECK-NEXT: [[P_64:%.*]] = bitcast i32* [[P]] to i64*
125 ; CHECK-NEXT: [[LV:%.*]] = load i64, i64* [[P_64]], align 8
126 ; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
128 ; CHECK-NEXT: br label [[BB3:%.*]]
130 ; CHECK-NEXT: br label [[BB3]]
132 ; CHECK-NEXT: store i32 2, i32* [[P]], align 4
133 ; CHECK-NEXT: ret void
136 %P.1 = getelementptr i32, i32* %P, i32 1
137 store i32 1, i32* %P.1
139 %P.64 = bitcast i32* %P to i64*
140 %lv = load i64, i64* %P.64
141 br i1 true, label %bb1, label %bb2
151 define void @test10(i32* %P) {
152 ; CHECK-LABEL: @test10(
153 ; CHECK-NEXT: store i32 0, i32* [[P:%.*]], align 4
154 ; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
156 ; CHECK-NEXT: store i32 1, i32* [[P]], align 4
157 ; CHECK-NEXT: br label [[BB3:%.*]]
159 ; CHECK-NEXT: ret void
161 ; CHECK-NEXT: ret void
164 br i1 true, label %bb1, label %bb2
175 define void @test11() {
176 ; CHECK-LABEL: @test11(
177 ; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
179 ; CHECK-NEXT: br label [[BB3:%.*]]
181 ; CHECK-NEXT: ret void
183 ; CHECK-NEXT: ret void
187 br i1 true, label %bb1, label %bb2
198 define void @test12(i32* %P) {
199 ; CHECK-LABEL: @test12(
200 ; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
202 ; CHECK-NEXT: store i32 1, i32* [[P:%.*]], align 4
203 ; CHECK-NEXT: br label [[BB3:%.*]]
205 ; CHECK-NEXT: store i32 1, i32* [[P]], align 4
206 ; CHECK-NEXT: ret void
208 ; CHECK-NEXT: ret void
211 br i1 true, label %bb1, label %bb2
223 define void @test13(i32* %P) {
224 ; CHECK-LABEL: @test13(
225 ; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
227 ; CHECK-NEXT: store i32 1, i32* [[P:%.*]], align 4
228 ; CHECK-NEXT: br label [[BB3:%.*]]
230 ; CHECK-NEXT: store i32 1, i32* [[P]], align 4
231 ; CHECK-NEXT: br label [[BB3]]
233 ; CHECK-NEXT: ret void
236 br i1 true, label %bb1, label %bb2