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 @test4(ptr noalias %P) {
9 ; CHECK-NEXT: store i32 0, ptr [[P:%.*]], align 4
10 ; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
12 ; CHECK-NEXT: br label [[BB3:%.*]]
14 ; CHECK-NEXT: [[X:%.*]] = load i32, ptr [[P]], align 4
15 ; CHECK-NEXT: br label [[BB3]]
17 ; CHECK-NEXT: store i32 1, ptr [[P]], align 4
18 ; CHECK-NEXT: ret void
21 br i1 true, label %bb1, label %bb2
32 define void @test5(ptr noalias %P) {
33 ; CHECK-LABEL: @test5(
34 ; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
36 ; CHECK-NEXT: br label [[BB3:%.*]]
38 ; CHECK-NEXT: br label [[BB3]]
40 ; CHECK-NEXT: store i32 0, ptr [[P:%.*]], align 4
41 ; CHECK-NEXT: ret void
43 br i1 true, label %bb1, label %bb2
55 define void @test8(ptr %P, ptr %Q) {
56 ; CHECK-LABEL: @test8(
57 ; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
59 ; CHECK-NEXT: br label [[BB3:%.*]]
61 ; CHECK-NEXT: store i32 1, ptr [[Q:%.*]], align 4
62 ; CHECK-NEXT: br label [[BB3]]
64 ; CHECK-NEXT: store i32 0, ptr [[P:%.*]], align 4
65 ; CHECK-NEXT: ret void
67 br i1 true, label %bb1, label %bb2
79 define void @test10(ptr noalias %P) {
80 ; CHECK-LABEL: @test10(
81 ; CHECK-NEXT: store i32 1, ptr [[P:%.*]], align 4
82 ; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
84 ; CHECK-NEXT: br label [[BB3:%.*]]
86 ; CHECK-NEXT: br label [[BB3]]
88 ; CHECK-NEXT: ret void
91 br i1 true, label %bb1, label %bb2
103 ; Check a function with a MemoryPhi with 3 incoming values.
104 define void @widget(ptr %Ptr, i1 %c1, i1 %c2, i32 %v1, i32 %v2, i32 %v3) {
105 ; CHECK-LABEL: @widget(
107 ; CHECK-NEXT: tail call void @hoge()
108 ; CHECK-NEXT: br i1 [[C1:%.*]], label [[BB3:%.*]], label [[BB1:%.*]]
110 ; CHECK-NEXT: br i1 [[C2:%.*]], label [[BB2:%.*]], label [[BB3]]
112 ; CHECK-NEXT: br label [[BB3]]
114 ; CHECK-NEXT: br label [[BB4:%.*]]
116 ; CHECK-NEXT: switch i32 [[V1:%.*]], label [[BB8:%.*]] [
117 ; CHECK-NEXT: i32 0, label [[BB5:%.*]]
118 ; CHECK-NEXT: i32 1, label [[BB6:%.*]]
119 ; CHECK-NEXT: i32 2, label [[BB7:%.*]]
122 ; CHECK-NEXT: store i32 0, ptr [[PTR:%.*]], align 4
123 ; CHECK-NEXT: br label [[BB8]]
125 ; CHECK-NEXT: store i32 1, ptr [[PTR]], align 4
126 ; CHECK-NEXT: br label [[BB8]]
128 ; CHECK-NEXT: store i32 2, ptr [[PTR]], align 4
129 ; CHECK-NEXT: br label [[BB8]]
131 ; CHECK-NEXT: br label [[BB4]]
134 tail call void @hoge()
135 br i1 %c1, label %bb3, label %bb1
138 br i1 %c2, label %bb2, label %bb3
141 store i32 -1, ptr %Ptr, align 4
144 bb3: ; preds = %bb2, %bb1, %bb
147 bb4: ; preds = %bb8, %bb3
148 switch i32 %v1, label %bb8 [
155 store i32 0, ptr %Ptr, align 4
159 store i32 1, ptr %Ptr, align 4
163 store i32 2, ptr %Ptr, align 4
166 bb8: ; preds = %bb7, %bb6, %bb5, %bb4
171 declare void @fn1_test11()
172 declare void @fn2_test11()
174 define void @test11(i1 %c, ptr %ptr.1) {
175 ; CHECK-LABEL: @test11(
177 ; CHECK-NEXT: br i1 [[C:%.*]], label [[IF_THEN:%.*]], label [[EXIT:%.*]]
179 ; CHECK-NEXT: tail call void @fn2_test11() #0
180 ; CHECK-NEXT: br label [[EXIT]]
182 ; CHECK-NEXT: store ptr null, ptr [[PTR_1:%.*]], align 8
183 ; CHECK-NEXT: tail call void @fn2_test11() #0
184 ; CHECK-NEXT: ret void
187 br i1 %c, label %if.then, label %exit
189 if.then: ; preds = %entry
190 tail call void @fn2_test11() #1
194 store ptr null, ptr %ptr.1, align 8
195 tail call void @fn2_test11() #1
199 attributes #1 = { nounwind }