1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=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(ptr 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, ptr [[P:%.*]], align 4
16 ; CHECK-NEXT: ret void
19 br i1 true, label %bb1, label %bb2
29 define void @test3(ptr noalias %P) {
30 ; CHECK-LABEL: @test3(
31 ; CHECK-NEXT: store i32 0, ptr [[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, ptr [[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(ptr noalias %P, ptr noalias %Q) {
54 ; CHECK-LABEL: @test7(
55 ; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
57 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[P:%.*]], align 4
58 ; CHECK-NEXT: br label [[BB3:%.*]]
60 ; CHECK-NEXT: br label [[BB3]]
62 ; CHECK-NEXT: store i32 0, ptr [[Q:%.*]], align 4
63 ; CHECK-NEXT: store i32 0, ptr [[P]], align 4
64 ; CHECK-NEXT: ret void
67 br i1 true, label %bb1, label %bb2
79 define i32 @test22(ptr %P, ptr noalias %Q, ptr %R) {
80 ; CHECK-LABEL: @test22(
81 ; CHECK-NEXT: store i32 2, ptr [[P:%.*]], align 4
82 ; CHECK-NEXT: store i32 3, ptr [[Q:%.*]], align 4
83 ; CHECK-NEXT: [[L:%.*]] = load i32, ptr [[R:%.*]], align 4
84 ; CHECK-NEXT: ret i32 [[L]]
93 define void @test9(ptr noalias %P) {
94 ; CHECK-LABEL: @test9(
95 ; CHECK-NEXT: store i32 0, ptr [[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, ptr [[P]], align 4
103 ; CHECK-NEXT: ret void
106 br i1 true, label %bb1, label %bb2
116 ; We cannot eliminate `store i32 0, ptr %P`, as it is read by the later load.
117 ; Make sure that we check the uses of `store i32 1, ptr %P.1 which does not
118 ; alias %P. Note that uses point to the *first* def that may alias.
119 define void @overlapping_read(ptr %P) {
120 ; CHECK-LABEL: @overlapping_read(
121 ; CHECK-NEXT: store i32 0, ptr [[P:%.*]], align 4
122 ; CHECK-NEXT: [[P_1:%.*]] = getelementptr i32, ptr [[P]], i32 1
123 ; CHECK-NEXT: store i32 1, ptr [[P_1]], align 4
124 ; CHECK-NEXT: [[LV:%.*]] = load i64, ptr [[P]], align 8
125 ; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
127 ; CHECK-NEXT: br label [[BB3:%.*]]
129 ; CHECK-NEXT: br label [[BB3]]
131 ; CHECK-NEXT: store i32 2, ptr [[P]], align 4
132 ; CHECK-NEXT: ret void
135 %P.1 = getelementptr i32, ptr %P, i32 1
136 store i32 1, ptr %P.1
138 %lv = load i64, ptr %P
139 br i1 true, label %bb1, label %bb2
149 define void @test10(ptr %P) {
150 ; CHECK-LABEL: @test10(
151 ; CHECK-NEXT: store i32 0, ptr [[P:%.*]], align 4
152 ; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
154 ; CHECK-NEXT: store i32 1, ptr [[P]], align 4
155 ; CHECK-NEXT: br label [[BB3:%.*]]
157 ; CHECK-NEXT: ret void
159 ; CHECK-NEXT: ret void
162 br i1 true, label %bb1, label %bb2
173 define void @test11() {
174 ; CHECK-LABEL: @test11(
175 ; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
177 ; CHECK-NEXT: br label [[BB3:%.*]]
179 ; CHECK-NEXT: ret void
181 ; CHECK-NEXT: ret void
185 br i1 true, label %bb1, label %bb2
196 define void @test12(ptr %P) {
197 ; CHECK-LABEL: @test12(
198 ; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
200 ; CHECK-NEXT: store i32 1, ptr [[P:%.*]], align 4
201 ; CHECK-NEXT: br label [[BB3:%.*]]
203 ; CHECK-NEXT: store i32 1, ptr [[P]], align 4
204 ; CHECK-NEXT: ret void
206 ; CHECK-NEXT: ret void
209 br i1 true, label %bb1, label %bb2
221 define void @test13(ptr %P) {
222 ; CHECK-LABEL: @test13(
223 ; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
225 ; CHECK-NEXT: store i32 1, ptr [[P:%.*]], align 4
226 ; CHECK-NEXT: br label [[BB3:%.*]]
228 ; CHECK-NEXT: store i32 1, ptr [[P]], align 4
229 ; CHECK-NEXT: br label [[BB3]]
231 ; CHECK-NEXT: ret void
234 br i1 true, label %bb1, label %bb2