This patch de-pessimizes the calculation of loop trip counts in

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
This commit is contained in:
Mark Heffernan
2014-10-10 17:39:11 +00:00
parent a64ffb893b
commit ed05e3703e
4 changed files with 335 additions and 377 deletions

View File

@@ -48,6 +48,6 @@ exit:
ret void
; CHECK-LABEL: @test3
; CHECK: Loop %loop: Unpredictable backedge-taken count.
; CHECK: Loop %loop: Unpredictable max backedge-taken count.
; 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)
}