llvm.org GIT mirror llvm / 9a2b615
[LoopUnrollRuntime] Bailout when multiple exiting blocks to the unique latch exit block Currently, we do not support multiple exiting blocks to the latch exit block. However, this bailout wasn't triggered when we had a unique exit block (which is the latch exit), with multiple exiting blocks to that unique exit. Moved the bailout so that it's triggered in both cases and added testcase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307291 91177308-0d34-0410-b5e6-96231b3b80d8 Anna Thomas 2 years ago
2 changed file(s) with 35 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
503503 // transformed.
504504 if (!PreserveLCSSA)
505505 return false;
506 // TODO: Support multiple exiting blocks jumping to the `LatchExit`. This
507 // will need updating the logic in connectEpilog.
508 if (!LatchExit->getSinglePredecessor())
509 return false;
510506 SmallVector Exits;
511507 L->getUniqueExitBlocks(Exits);
512508 for (auto *BB : Exits)
516512
517513 assert(LatchExit && "Latch Exit should exist!");
518514
515 // TODO: Support multiple exiting blocks jumping to the `LatchExit` when
516 // UnrollRuntimeMultiExit is true. This will need updating the logic in
517 // connectEpilog.
518 if (!LatchExit->getSinglePredecessor())
519 return false;
519520 // Use Scalar Evolution to compute the trip count. This allows more loops to
520521 // be unrolled than relying on induction var simplification.
521522 if (!SE)
183183 ret i32 42
184184 }
185185
186 ; FIXME: Support multiple exiting blocks to the unique exit block.
187 define void @unique_exit(i32 %arg) {
188 ; CHECK-LABEL: unique_exit
189 ; CHECK-NOT: .unr
190 ; CHECK-NOT: .epil
191 entry:
192 %tmp = icmp sgt i32 undef, %arg
193 br i1 %tmp, label %preheader, label %returnblock
194
195 preheader: ; preds = %entry
196 br label %header
197
198 LoopExit: ; preds = %header, %latch
199 %tmp2.ph = phi i32 [ %tmp4, %header ], [ -1, %latch ]
200 br label %returnblock
201
202 returnblock: ; preds = %LoopExit, %entry
203 %tmp2 = phi i32 [ -1, %entry ], [ %tmp2.ph, %LoopExit ]
204 ret void
205
206 header: ; preds = %preheader, %latch
207 %tmp4 = phi i32 [ %inc, %latch ], [ %arg, %preheader ]
208 %inc = add nsw i32 %tmp4, 1
209 br i1 true, label %LoopExit, label %latch
210
211 latch: ; preds = %header
212 %cmp = icmp slt i32 %inc, undef
213 br i1 %cmp, label %header, label %LoopExit
214 }
215
186216 ; two exiting and two exit blocks.
187217 ; the non-latch exiting block has duplicate edges to the non-latch exit block.
188218 define i64 @test5(i64 %trip, i64 %add, i1 %cond) {