mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-08 04:51:23 +00:00
ed05e3703e
ScalarEvolution in the presence of multiple exits. Previously all loops exits had to have identical counts for a loop trip count to be considered computable. This pessimization was implemented by calling getBackedgeTakenCount(L) rather than getExitCount(L, ExitingBlock) inside of ScalarEvolution::getSmallConstantTripCount() (see the FIXME in the comments of that function). The pessimization was added to fix a corner case involving undefined behavior (pr/16130). This patch more precisely handles the undefined behavior case allowing the pessimization to be removed. ControlsExit replaces IsSubExpr to more precisely track the case where undefined behavior is expected to occur. Because undefined behavior is tracked more precisely we can remove MustExit from ExitLimit. MustExit was used to track the case where the limit was computed potentially assuming undefined behavior even if undefined behavior didn't necessarily occur. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219517 91177308-0d34-0410-b5e6-96231b3b80d8
54 lines
1.3 KiB
LLVM
54 lines
1.3 KiB
LLVM
; RUN: opt < %s -scalar-evolution -analyze | FileCheck %s
|
|
|
|
define void @test1(i32 %n) {
|
|
entry:
|
|
%s = mul i32 %n, 96
|
|
br label %loop
|
|
loop:
|
|
%i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
|
|
%i.next = add i32 %i, 32
|
|
%t = icmp ne i32 %i.next, %s
|
|
br i1 %t, label %loop, label %exit
|
|
exit:
|
|
ret void
|
|
|
|
; CHECK-LABEL: @test1
|
|
; CHECK: Loop %loop: backedge-taken count is ((-32 + (96 * %n)) /u 32)
|
|
; CHECK: Loop %loop: max backedge-taken count is ((-32 + (96 * %n)) /u 32)
|
|
}
|
|
|
|
; PR19183
|
|
define i32 @test2(i32 %n) {
|
|
entry:
|
|
%s = and i32 %n, -32
|
|
br label %loop
|
|
loop:
|
|
%i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
|
|
%i.next = add i32 %i, 32
|
|
%t = icmp ne i32 %i.next, %s
|
|
br i1 %t, label %loop, label %exit
|
|
exit:
|
|
ret i32 %i
|
|
|
|
; CHECK-LABEL: @test2
|
|
; CHECK: Loop %loop: backedge-taken count is ((-32 + (32 * (%n /u 32))) /u 32)
|
|
; CHECK: Loop %loop: max backedge-taken count is ((-32 + (32 * (%n /u 32))) /u 32)
|
|
}
|
|
|
|
define void @test3(i32 %n) {
|
|
entry:
|
|
%s = mul i32 %n, 96
|
|
br label %loop
|
|
loop:
|
|
%i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
|
|
%i.next = add i32 %i, 96
|
|
%t = icmp ne i32 %i.next, %s
|
|
br i1 %t, label %loop, label %exit
|
|
exit:
|
|
ret void
|
|
|
|
; CHECK-LABEL: @test3
|
|
; CHECK: Loop %loop: backedge-taken count is ((-96 + (96 * %n)) /u 96)
|
|
; CHECK: Loop %loop: max backedge-taken count is ((-96 + (96 * %n)) /u 96)
|
|
}
|