• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -basic-aa -dse -S | FileCheck %s
3
4target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
5
6
7define void @test4(i32* noalias %P) {
8; CHECK-LABEL: @test4(
9; CHECK-NEXT:    store i32 0, i32* [[P:%.*]], align 4
10; CHECK-NEXT:    br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
11; CHECK:       bb1:
12; CHECK-NEXT:    br label [[BB3:%.*]]
13; CHECK:       bb2:
14; CHECK-NEXT:    [[X:%.*]] = load i32, i32* [[P]], align 4
15; CHECK-NEXT:    br label [[BB3]]
16; CHECK:       bb3:
17; CHECK-NEXT:    store i32 0, i32* [[P]], align 4
18; CHECK-NEXT:    ret void
19;
20  store i32 0, i32* %P
21  br i1 true, label %bb1, label %bb2
22bb1:
23  br label %bb3
24bb2:
25  %x = load i32, i32* %P
26  br label %bb3
27bb3:
28  store i32 0, i32* %P
29  ret void
30}
31
32define void @test5(i32* noalias %P) {
33; CHECK-LABEL: @test5(
34; CHECK-NEXT:    br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
35; CHECK:       bb1:
36; CHECK-NEXT:    br label [[BB3:%.*]]
37; CHECK:       bb2:
38; CHECK-NEXT:    br label [[BB3]]
39; CHECK:       bb3:
40; CHECK-NEXT:    store i32 0, i32* [[P:%.*]], align 4
41; CHECK-NEXT:    ret void
42;
43  br i1 true, label %bb1, label %bb2
44bb1:
45  store i32 1, i32* %P
46  br label %bb3
47bb2:
48  store i32 1, i32* %P
49  br label %bb3
50bb3:
51  store i32 0, i32* %P
52  ret void
53}
54
55define void @test8(i32* %P, i32* %Q) {
56; CHECK-LABEL: @test8(
57; CHECK-NEXT:    br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
58; CHECK:       bb1:
59; CHECK-NEXT:    br label [[BB3:%.*]]
60; CHECK:       bb2:
61; CHECK-NEXT:    store i32 1, i32* [[Q:%.*]], align 4
62; CHECK-NEXT:    br label [[BB3]]
63; CHECK:       bb3:
64; CHECK-NEXT:    store i32 0, i32* [[P:%.*]], align 4
65; CHECK-NEXT:    ret void
66;
67  br i1 true, label %bb1, label %bb2
68bb1:
69  store i32 1, i32* %P
70  br label %bb3
71bb2:
72  store i32 1, i32* %Q
73  br label %bb3
74bb3:
75  store i32 0, i32* %P
76  ret void
77}
78
79define void @test10(i32* noalias %P) {
80; CHECK-LABEL: @test10(
81; CHECK-NEXT:    store i32 1, i32* [[P:%.*]], align 4
82; CHECK-NEXT:    br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
83; CHECK:       bb1:
84; CHECK-NEXT:    br label [[BB3:%.*]]
85; CHECK:       bb2:
86; CHECK-NEXT:    br label [[BB3]]
87; CHECK:       bb3:
88; CHECK-NEXT:    ret void
89;
90  %P2 = bitcast i32* %P to i8*
91  store i32 0, i32* %P
92  br i1 true, label %bb1, label %bb2
93bb1:
94  br label %bb3
95bb2:
96  br label %bb3
97bb3:
98  store i8 1, i8* %P2
99  ret void
100}
101
102declare void @hoge()
103
104; Check a function with a MemoryPhi with 3 incoming values.
105define void @widget(i32* %Ptr, i1 %c1, i1 %c2, i32 %v1, i32 %v2, i32 %v3) {
106; CHECK-LABEL: @widget(
107; CHECK-NEXT:  bb:
108; CHECK-NEXT:    tail call void @hoge()
109; CHECK-NEXT:    br i1 [[C1:%.*]], label [[BB3:%.*]], label [[BB1:%.*]]
110; CHECK:       bb1:
111; CHECK-NEXT:    br i1 [[C2:%.*]], label [[BB2:%.*]], label [[BB3]]
112; CHECK:       bb2:
113; CHECK-NEXT:    br label [[BB3]]
114; CHECK:       bb3:
115; CHECK-NEXT:    br label [[BB4:%.*]]
116; CHECK:       bb4:
117; CHECK-NEXT:    switch i32 [[V1:%.*]], label [[BB8:%.*]] [
118; CHECK-NEXT:    i32 0, label [[BB5:%.*]]
119; CHECK-NEXT:    i32 1, label [[BB6:%.*]]
120; CHECK-NEXT:    i32 2, label [[BB7:%.*]]
121; CHECK-NEXT:    ]
122; CHECK:       bb5:
123; CHECK-NEXT:    store i32 0, i32* [[PTR:%.*]], align 4
124; CHECK-NEXT:    br label [[BB8]]
125; CHECK:       bb6:
126; CHECK-NEXT:    store i32 1, i32* [[PTR]], align 4
127; CHECK-NEXT:    br label [[BB8]]
128; CHECK:       bb7:
129; CHECK-NEXT:    store i32 2, i32* [[PTR]], align 4
130; CHECK-NEXT:    br label [[BB8]]
131; CHECK:       bb8:
132; CHECK-NEXT:    br label [[BB4]]
133;
134bb:
135  tail call void @hoge()
136  br i1 %c1, label %bb3, label %bb1
137
138bb1:                                              ; preds = %bb
139  br i1 %c2, label %bb2, label %bb3
140
141bb2:                                              ; preds = %bb1
142  store i32 -1, i32* %Ptr, align 4
143  br label %bb3
144
145bb3:                                              ; preds = %bb2, %bb1, %bb
146  br label %bb4
147
148bb4:                                              ; preds = %bb8, %bb3
149  switch i32 %v1, label %bb8 [
150  i32 0, label %bb5
151  i32 1, label %bb6
152  i32 2, label %bb7
153  ]
154
155bb5:                                              ; preds = %bb4
156  store i32 0, i32* %Ptr, align 4
157  br label %bb8
158
159bb6:                                              ; preds = %bb4
160  store i32 1, i32* %Ptr, align 4
161  br label %bb8
162
163bb7:                                              ; preds = %bb4
164  store i32 2, i32* %Ptr, align 4
165  br label %bb8
166
167bb8:                                              ; preds = %bb7, %bb6, %bb5, %bb4
168  br label %bb4
169}
170
171
172declare void @fn1_test11()
173declare void @fn2_test11()
174
175define void @test11(i1 %c, i8** %ptr.1) {
176; CHECK-LABEL: @test11(
177; CHECK-NEXT:  entry:
178; CHECK-NEXT:    br i1 [[C:%.*]], label [[IF_THEN:%.*]], label [[EXIT:%.*]]
179; CHECK:       if.then:
180; CHECK-NEXT:    tail call void @fn2_test11() #0
181; CHECK-NEXT:    br label [[EXIT]]
182; CHECK:       exit:
183; CHECK-NEXT:    store i8* null, i8** [[PTR_1:%.*]], align 8
184; CHECK-NEXT:    tail call void @fn2_test11() #0
185; CHECK-NEXT:    ret void
186;
187entry:
188  br i1 %c, label %if.then, label %exit
189
190if.then:                                      ; preds = %entry
191  tail call void @fn2_test11() #1
192  br label %exit
193
194exit:
195  store i8* null, i8** %ptr.1, align 8
196  tail call void @fn2_test11() #1
197  ret void
198}
199
200attributes #1 = { nounwind }
201