forked from OSchip/llvm-project
[IRCE] Use the same min runtime iteration threshold for BPI and BFI checks
In the last change to IRCE the BPI is ignored if BFI is present, however BFI and BPI have a different thresholds. Specifically BPI approach checks only latch exit probability so it is expected if the loop has only one exit block (latch) the behavior with BFI and BPI should be the same, BPI approach by default uses threshold 10, so it considers the loop with estimated number of iterations less then 10 should not be considered for IRCE optimization. BFI approach uses the default value 3 and this is inconsistent. The CL modifies the code to use the same threshold for both approaches.. The test is updated due to it has two side-exits (except latch) and each of them has a probability 1/16, so BFI estimates the number of runtime iteration is about to 7 (1/16 + 1/16 + some for latch) and test fails. Reviewers: mkazantsev, ebrevnov Reviewed By: mkazantsev Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D91230
This commit is contained in:
parent
c22dc71b12
commit
400f6edce7
|
@ -110,14 +110,11 @@ static cl::opt<bool> PrintChangedLoops("irce-print-changed-loops", cl::Hidden,
|
||||||
static cl::opt<bool> PrintRangeChecks("irce-print-range-checks", cl::Hidden,
|
static cl::opt<bool> PrintRangeChecks("irce-print-range-checks", cl::Hidden,
|
||||||
cl::init(false));
|
cl::init(false));
|
||||||
|
|
||||||
static cl::opt<int> MaxExitProbReciprocal("irce-max-exit-prob-reciprocal",
|
|
||||||
cl::Hidden, cl::init(10));
|
|
||||||
|
|
||||||
static cl::opt<bool> SkipProfitabilityChecks("irce-skip-profitability-checks",
|
static cl::opt<bool> SkipProfitabilityChecks("irce-skip-profitability-checks",
|
||||||
cl::Hidden, cl::init(false));
|
cl::Hidden, cl::init(false));
|
||||||
|
|
||||||
static cl::opt<unsigned> MinRuntimeIterations("min-runtime-iterations",
|
static cl::opt<unsigned> MinRuntimeIterations("irce-min-runtime-iterations",
|
||||||
cl::Hidden, cl::init(3));
|
cl::Hidden, cl::init(10));
|
||||||
|
|
||||||
static cl::opt<bool> AllowUnsignedLatchCondition("irce-allow-unsigned-latch",
|
static cl::opt<bool> AllowUnsignedLatchCondition("irce-allow-unsigned-latch",
|
||||||
cl::Hidden, cl::init(true));
|
cl::Hidden, cl::init(true));
|
||||||
|
@ -1871,7 +1868,7 @@ InductiveRangeCheckElimination::isProfitableToTransform(const Loop &L,
|
||||||
return true;
|
return true;
|
||||||
BranchProbability ExitProbability =
|
BranchProbability ExitProbability =
|
||||||
BPI->getEdgeProbability(LS.Latch, LS.LatchBrExitIdx);
|
BPI->getEdgeProbability(LS.Latch, LS.LatchBrExitIdx);
|
||||||
if (ExitProbability > BranchProbability(1, MaxExitProbReciprocal)) {
|
if (ExitProbability > BranchProbability(1, MinRuntimeIterations)) {
|
||||||
LLVM_DEBUG(dbgs() << "irce: could not prove profitability: "
|
LLVM_DEBUG(dbgs() << "irce: could not prove profitability: "
|
||||||
<< "the exit probability is too big " << ExitProbability
|
<< "the exit probability is too big " << ExitProbability
|
||||||
<< "\n";);
|
<< "\n";);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
; RUN: opt -verify-loop-info -irce-print-changed-loops -passes=irce -min-runtime-iterations=3 < %s 2>&1 | FileCheck %s --check-prefixes=CHECK-NO
|
; RUN: opt -verify-loop-info -irce-print-changed-loops -passes=irce -irce-min-runtime-iterations=3 < %s 2>&1 | FileCheck %s --check-prefixes=CHECK-NO
|
||||||
; RUN: opt -verify-loop-info -irce-print-changed-loops -passes=irce -min-runtime-iterations=0 < %s 2>&1 | FileCheck %s --check-prefixes=CHECK-YES
|
; RUN: opt -verify-loop-info -irce-print-changed-loops -passes=irce -irce-min-runtime-iterations=0 < %s 2>&1 | FileCheck %s --check-prefixes=CHECK-YES
|
||||||
|
|
||||||
; CHECK-YES: constrained Loop
|
; CHECK-YES: constrained Loop
|
||||||
; CHECK-NO-NOT: constrained Loop
|
; CHECK-NO-NOT: constrained Loop
|
||||||
|
|
|
@ -60,4 +60,4 @@ define void @multiple_access_no_preloop(
|
||||||
; CHECK: br i1 %next.postloop, label %loop.postloop, label %exit.loopexit
|
; CHECK: br i1 %next.postloop, label %loop.postloop, label %exit.loopexit
|
||||||
|
|
||||||
!0 = !{i32 0, i32 2147483647}
|
!0 = !{i32 0, i32 2147483647}
|
||||||
!1 = !{!"branch_weights", i32 64, i32 4}
|
!1 = !{!"branch_weights", i32 128, i32 4}
|
||||||
|
|
Loading…
Reference in New Issue