Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,8 @@ tryToUnrollLoop(Loop *L, DominatorTree &DT, LoopInfo *LI, ScalarEvolution &SE,
}

// Do not attempt partial/runtime unrolling in FullLoopUnrolling
if (OnlyFullUnroll && (UP.Count < TripCount || UP.Count < MaxTripCount)) {
if (OnlyFullUnroll && ((!TripCount && !MaxTripCount) ||
UP.Count < TripCount || UP.Count < MaxTripCount)) {
LLVM_DEBUG(
dbgs() << "Not attempting partial/runtime unroll in FullLoopUnroll.\n");
return LoopUnrollResult::Unmodified;
Expand Down
29 changes: 29 additions & 0 deletions llvm/test/Transforms/LoopUnroll/full-unroll-avoid-partial.ll
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,35 @@ for.body: ; preds = %for.body.preheader,
br i1 %exitcond, label %for.body, label %for.cond.cleanup.loopexit, !llvm.loop !3
}

; LOOP-UNROLL-LABEL: Loop Unroll: F[pragma_unroll_count2] Loop %for.body
; LOOP-UNROLL-NEXT: Loop Size = 4
; LOOP-UNROLL-NEXT: Exiting block %for.body: TripCount=0, TripMultiple=1, BreakoutTrip=1
; LOOP-UNROLL-NEXT: Trying runtime unrolling on Loop:
; LOOP-UNROLL-NEXT: Loop at depth 1 containing: %for.body<header><exiting>,%for.cond<latch>
; LOOP-UNROLL-NEXT: Using epilog remainder.
; LOOP-UNROLL-NEXT: Loop latch not terminated by a conditional branch.
; LOOP-UNROLL-NEXT: UNROLLING loop %for.body by 5!

; LOOP-UNROLL-FULL-LABEL: Loop Unroll: F[pragma_unroll_count2] Loop %for.body
; LOOP-UNROLL-FULL-NEXT: Loop Size = 4
; LOOP-UNROLL-FULL-NEXT: Not attempting partial/runtime unroll in FullLoopUnroll
define void @pragma_unroll_count2(i64 %n) {
entry:
br label %for.body

for.body: ; preds = %for.cond, %entry
%i = phi i64 [ 0, %entry ], [ %inc, %for.cond ]
%cmp = icmp ult i64 %i, %n
br i1 %cmp, label %for.cond, label %for.cond.cleanup

for.cond: ; preds = %for.body
%inc = add i64 %i, 8
br label %for.body, !llvm.loop !3

for.cond.cleanup: ; preds = %for.body
ret void
}

; LOOP-UNROLL: llvm.loop.unroll.disable
; LOOP-UNROLL-FULL: llvm.loop.unroll.enable
!0 = !{!"llvm.loop.unroll.enable"}
Expand Down
Loading