mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
a17845f6c0
Loop peeling is currently performed as part of UnrollLoop(). Outside test scenarios, it is always performed with an unroll count of 1. This means that unrolling doesn't actually do anything apart from performing post-unroll simplification. When testing, it's currently possible to specify both an explicit peel count and an explicit unroll count. This doesn't perform any sensible operation and may result in miscompiles, see https://bugs.llvm.org/show_bug.cgi?id=45939. This patch moves peeling from UnrollLoop() into tryToUnrollLoop(), so that peeling does not also perform a susequent unroll. We only run the post-unroll simplifications. Specifying both an explicit peel count and unroll count is forbidden. In the future, we may want to support both (non-PGO) peeling a loop and unrolling it, but this needs to be done by first performing the peel and then recalculating unrolling heuristics on a now possibly analyzable loop. Differential Revision: https://reviews.llvm.org/D103362
94 lines
3.0 KiB
LLVM
94 lines
3.0 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; RUN: opt -S -loop-unroll -unroll-peel-count=1 < %s | FileCheck %s
|
|
|
|
declare zeroext i8 @patatino()
|
|
|
|
define fastcc void @tinky() {
|
|
; CHECK-LABEL: @tinky(
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: br label [[NEXT:%.*]]
|
|
; CHECK: loopexit.loopexit:
|
|
; CHECK-NEXT: br label [[LOOPEXIT:%.*]]
|
|
; CHECK: loopexit:
|
|
; CHECK-NEXT: ret void
|
|
; CHECK: next:
|
|
; CHECK-NEXT: br label [[LOOP_PEEL_BEGIN:%.*]]
|
|
; CHECK: loop.peel.begin:
|
|
; CHECK-NEXT: br label [[LOOP_PEEL:%.*]]
|
|
; CHECK: loop.peel:
|
|
; CHECK-NEXT: [[CALL593_PEEL:%.*]] = tail call zeroext i8 @patatino()
|
|
; CHECK-NEXT: br i1 false, label [[LOOP_PEEL_NEXT:%.*]], label [[LOOPEXIT]]
|
|
; CHECK: loop.peel.next:
|
|
; CHECK-NEXT: br label [[LOOP_PEEL_NEXT1:%.*]]
|
|
; CHECK: loop.peel.next1:
|
|
; CHECK-NEXT: br label [[NEXT_PEEL_NEWPH:%.*]]
|
|
; CHECK: next.peel.newph:
|
|
; CHECK-NEXT: br label [[LOOP:%.*]]
|
|
; CHECK: loop:
|
|
; CHECK-NEXT: [[CALL593:%.*]] = tail call zeroext i8 @patatino()
|
|
; CHECK-NEXT: br i1 false, label [[LOOP]], label [[LOOPEXIT_LOOPEXIT:%.*]], !llvm.loop [[LOOP0:![0-9]+]]
|
|
;
|
|
entry:
|
|
br label %next
|
|
|
|
loopexit:
|
|
ret void
|
|
|
|
next:
|
|
br label %loop
|
|
|
|
loop:
|
|
%a = phi i8 [ undef, %next ], [ %call593, %loop ]
|
|
%b = phi i32 [ 0, %next ], [ 1, %loop ]
|
|
%call593 = tail call zeroext i8 @patatino()
|
|
br i1 false, label %loop, label %loopexit
|
|
}
|
|
|
|
define void @tinky2() {
|
|
; CHECK-LABEL: @tinky2(
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: br label [[NEXT:%.*]]
|
|
; CHECK: loopexit.loopexit:
|
|
; CHECK-NEXT: br label [[LOOPEXIT:%.*]]
|
|
; CHECK: loopexit:
|
|
; CHECK-NEXT: ret void
|
|
; CHECK: next:
|
|
; CHECK-NEXT: br label [[LOOP_PEEL_BEGIN:%.*]]
|
|
; CHECK: loop.peel.begin:
|
|
; CHECK-NEXT: br label [[LOOP_PEEL:%.*]]
|
|
; CHECK: loop.peel:
|
|
; CHECK-NEXT: [[CALL593_PEEL:%.*]] = tail call zeroext i8 @patatino()
|
|
; CHECK-NEXT: [[B_NEXT_PEEL:%.*]] = add i32 0, 1
|
|
; CHECK-NEXT: [[COND_PEEL:%.*]] = icmp ne i32 0, 30
|
|
; CHECK-NEXT: br i1 [[COND_PEEL]], label [[LOOP_PEEL_NEXT:%.*]], label [[LOOPEXIT]]
|
|
; CHECK: loop.peel.next:
|
|
; CHECK-NEXT: br label [[LOOP_PEEL_NEXT1:%.*]]
|
|
; CHECK: loop.peel.next1:
|
|
; CHECK-NEXT: br label [[NEXT_PEEL_NEWPH:%.*]]
|
|
; CHECK: next.peel.newph:
|
|
; CHECK-NEXT: br label [[LOOP:%.*]]
|
|
; CHECK: loop:
|
|
; CHECK-NEXT: [[B:%.*]] = phi i32 [ [[B_NEXT_PEEL]], [[NEXT_PEEL_NEWPH]] ], [ [[B_NEXT:%.*]], [[LOOP]] ]
|
|
; CHECK-NEXT: [[CALL593:%.*]] = tail call zeroext i8 @patatino()
|
|
; CHECK-NEXT: [[B_NEXT]] = add nuw nsw i32 [[B]], 1
|
|
; CHECK-NEXT: [[COND:%.*]] = icmp ne i32 [[B]], 30
|
|
; CHECK-NEXT: br i1 [[COND]], label [[LOOP]], label [[LOOPEXIT_LOOPEXIT:%.*]], !llvm.loop [[LOOP3:![0-9]+]]
|
|
;
|
|
entry:
|
|
br label %next
|
|
|
|
loopexit:
|
|
ret void
|
|
|
|
next:
|
|
br label %loop
|
|
|
|
loop:
|
|
%a = phi i8 [ undef, %next ], [ %call593, %loop ]
|
|
%b = phi i32 [ 0, %next ], [ %b.next, %loop ]
|
|
%call593 = tail call zeroext i8 @patatino()
|
|
%b.next = add i32 %b, 1
|
|
%cond = icmp ne i32 %b, 30
|
|
br i1 %cond, label %loop, label %loopexit
|
|
}
|