1 ; RUN: opt < %s -disable-output -branch-prob -instcombine -block-freq -verify-dom-info
2 ; RUN: opt < %s -postdomtree -analyze -enable-new-pm=0 | FileCheck --check-prefixes=CHECK-POSTDOM %s
3 ; RUN: opt < %s -passes='print<postdomtree>' 2>&1 | FileCheck --check-prefixes=CHECK-POSTDOM %s
5 ; Demonstrate that Predicate Canonicalization (InstCombine) does not invalidate PostDomTree
6 ; if the basic block is post-dom unreachable.
8 define void @test1(i24 %a, i24 %b) {
13 %f = icmp uge i24 %a, %b
14 br i1 %f, label %B1, label %B2
24 ; The same as @test1 except the LOOP condition canonicalized (as by instcombine).
25 define void @test1-canonicalized(i24 %a, i24 %b) {
30 %f.not = icmp ult i24 %a, %b
31 br i1 %f.not, label %B2, label %B1
41 ; The same as @test1 but different order of B1 and B2 in the function.
42 ; The different order makes PostDomTree different in presense of postdom
44 define void @test2(i24 %a, i24 %b) {
49 %f = icmp uge i24 %a, %b
50 br i1 %f, label %B1, label %B2
60 ; The same as @test2 except the LOOP condition canonicalized (as by instcombine).
61 define void @test2-canonicalized(i24 %a, i24 %b) {
66 %f.not = icmp ult i24 %a, %b
67 br i1 %f.not, label %B2, label %B1
77 ; Two reverse unreachable subgraphs with RU1* and RU2* basic blocks respectively.
78 define void @test3(i24 %a, i24 %b, i32 %flag) {
80 switch i32 %flag, label %EXIT [
87 %f = icmp uge i24 %a, %b
91 br i1 %f, label %RU1_B1, label %RU1_B2
101 %f2 = icmp uge i24 %a, %b
102 br i1 %f2, label %RU2_B1, label %RU2_B2
114 ; The same as @test3 except the icmp conditions are canonicalized (as by instcombine).
115 define void @test3-canonicalized(i24 %a, i24 %b, i32 %flag) {
117 switch i32 %flag, label %EXIT [
124 %f.not = icmp ult i24 %a, %b
128 br i1 %f.not, label %RU1_B2, label %RU1_B1
138 %f2.not = icmp ult i24 %a, %b
139 br i1 %f2.not, label %RU2_B2, label %RU2_B1
151 ; PostDomTrees of @test1(), @test2() and @test3() are different.
152 ; PostDomTrees of @testX() and @testX-canonicalize() are the same.
154 ; CHECK-POSTDOM-LABEL: test1
155 ; CHECK-POSTDOM-NEXT: =============================--------------------------------
156 ; CHECK-POSTDOM-NEXT: Inorder PostDominator Tree: DFSNumbers invalid: 0 slow queries.
157 ; CHECK-POSTDOM-NEXT: [1] <<exit node>>
158 ; CHECK-POSTDOM-NEXT: [2] %B1
159 ; CHECK-POSTDOM-NEXT: [3] %LOOP
160 ; CHECK-POSTDOM-NEXT: [4] %entry
161 ; CHECK-POSTDOM-NEXT: [4] %B2
162 ; CHECK-POSTDOM-NEXT: Roots: %B1
164 ; CHECK-POSTDOM-LABEL: test1-canonicalized
165 ; CHECK-POSTDOM-NEXT: =============================--------------------------------
166 ; CHECK-POSTDOM-NEXT: Inorder PostDominator Tree: DFSNumbers invalid: 0 slow queries.
167 ; CHECK-POSTDOM-NEXT: [1] <<exit node>>
168 ; CHECK-POSTDOM-NEXT: [2] %B1
169 ; CHECK-POSTDOM-NEXT: [3] %LOOP
170 ; CHECK-POSTDOM-NEXT: [4] %entry
171 ; CHECK-POSTDOM-NEXT: [4] %B2
172 ; CHECK-POSTDOM-NEXT: Roots: %B1
174 ; CHECK-POSTDOM-LABEL: test2
175 ; CHECK-POSTDOM-NEXT: =============================--------------------------------
176 ; CHECK-POSTDOM-NEXT: Inorder PostDominator Tree: DFSNumbers invalid: 0 slow queries.
177 ; CHECK-POSTDOM-NEXT: [1] <<exit node>>
178 ; CHECK-POSTDOM-NEXT: [2] %B2
179 ; CHECK-POSTDOM-NEXT: [3] %LOOP
180 ; CHECK-POSTDOM-NEXT: [4] %entry
181 ; CHECK-POSTDOM-NEXT: [3] %B1
182 ; CHECK-POSTDOM-NEXT: Roots: %B2
184 ; CHECK-POSTDOM-LABEL: test2-canonicalized
185 ; CHECK-POSTDOM-NEXT: =============================--------------------------------
186 ; CHECK-POSTDOM-NEXT: Inorder PostDominator Tree: DFSNumbers invalid: 0 slow queries.
187 ; CHECK-POSTDOM-NEXT: [1] <<exit node>>
188 ; CHECK-POSTDOM-NEXT: [2] %B2
189 ; CHECK-POSTDOM-NEXT: [3] %LOOP
190 ; CHECK-POSTDOM-NEXT: [4] %entry
191 ; CHECK-POSTDOM-NEXT: [3] %B1
192 ; CHECK-POSTDOM-NEXT: Roots: %B2
194 ; CHECK-POSTDOM-LABEL: test3
195 ; CHECK-POSTDOM-NEXT:=============================--------------------------------
196 ; CHECK-POSTDOM-NEXT:Inorder PostDominator Tree: DFSNumbers invalid: 0 slow queries.
197 ; CHECK-POSTDOM-NEXT: [1] <<exit node>>
198 ; CHECK-POSTDOM-NEXT: [2] %EXIT
199 ; CHECK-POSTDOM-NEXT: [2] %entry
200 ; CHECK-POSTDOM-NEXT: [2] %RU1_B1
201 ; CHECK-POSTDOM-NEXT: [3] %RU1_LOOP
202 ; CHECK-POSTDOM-NEXT: [4] %RU1
203 ; CHECK-POSTDOM-NEXT: [4] %RU1_B2
204 ; CHECK-POSTDOM-NEXT: [2] %RU2_B1
205 ; CHECK-POSTDOM-NEXT: [3] %RU2
206 ; CHECK-POSTDOM-NEXT: [3] %RU2_B2
207 ; CHECK-POSTDOM-NEXT:Roots: %EXIT %RU1_B1 %RU2_B1
209 ; CHECK-POSTDOM-LABEL: test3-canonicalized
210 ; CHECK-POSTDOM-NEXT:=============================--------------------------------
211 ; CHECK-POSTDOM-NEXT:Inorder PostDominator Tree: DFSNumbers invalid: 0 slow queries.
212 ; CHECK-POSTDOM-NEXT: [1] <<exit node>>
213 ; CHECK-POSTDOM-NEXT: [2] %EXIT
214 ; CHECK-POSTDOM-NEXT: [2] %entry
215 ; CHECK-POSTDOM-NEXT: [2] %RU1_B1
216 ; CHECK-POSTDOM-NEXT: [3] %RU1_LOOP
217 ; CHECK-POSTDOM-NEXT: [4] %RU1
218 ; CHECK-POSTDOM-NEXT: [4] %RU1_B2
219 ; CHECK-POSTDOM-NEXT: [2] %RU2_B1
220 ; CHECK-POSTDOM-NEXT: [3] %RU2
221 ; CHECK-POSTDOM-NEXT: [3] %RU2_B2
222 ; CHECK-POSTDOM-NEXT:Roots: %EXIT %RU1_B1 %RU2_B1