[IRCE] Add an option to skip profitability checks
If `-irce-skip-profitability-checks` is passed in, IRCE will kick in in all cases where it is legal for it to kick in. This flag is intended to help diagnose and analyse performance issues. llvm-svn: 276372
This commit is contained in:
parent
0c5b92cae6
commit
bb969791b4
|
@ -82,6 +82,9 @@ static cl::opt<bool> PrintRangeChecks("irce-print-range-checks", cl::Hidden,
|
|||
static cl::opt<int> MaxExitProbReciprocal("irce-max-exit-prob-reciprocal",
|
||||
cl::Hidden, cl::init(10));
|
||||
|
||||
static cl::opt<bool> SkipProfitabilityChecks("irce-skip-profitability-checks",
|
||||
cl::Hidden, cl::init(false));
|
||||
|
||||
#define DEBUG_TYPE "irce"
|
||||
|
||||
namespace {
|
||||
|
@ -392,7 +395,8 @@ void InductiveRangeCheck::extractRangeChecksFromBranch(
|
|||
|
||||
BranchProbability LikelyTaken(15, 16);
|
||||
|
||||
if (BPI.getEdgeProbability(BI->getParent(), (unsigned)0) < LikelyTaken)
|
||||
if (!SkipProfitabilityChecks &&
|
||||
BPI.getEdgeProbability(BI->getParent(), (unsigned)0) < LikelyTaken)
|
||||
return;
|
||||
|
||||
SmallPtrSet<Value *, 8> Visited;
|
||||
|
@ -648,7 +652,8 @@ LoopStructure::parseLoopStructure(ScalarEvolution &SE, BranchProbabilityInfo &BP
|
|||
BranchProbability ExitProbability =
|
||||
BPI.getEdgeProbability(LatchBr->getParent(), LatchBrExitIdx);
|
||||
|
||||
if (ExitProbability > BranchProbability(1, MaxExitProbReciprocal)) {
|
||||
if (!SkipProfitabilityChecks &&
|
||||
ExitProbability > BranchProbability(1, MaxExitProbReciprocal)) {
|
||||
FailureReason = "short running loop, not profitable";
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
; RUN: opt -irce-skip-profitability-checks -S -irce < %s | FileCheck %s
|
||||
|
||||
define void @single_access_no_preloop_no_offset(i32 *%arr, i32 *%a_len_ptr, i32 %n) {
|
||||
; CHECK-LABEL: @single_access_no_preloop_no_offset(
|
||||
; CHECK: main.exit.selector:
|
||||
entry:
|
||||
%len = load i32, i32* %a_len_ptr, !range !0
|
||||
%first.itr.check = icmp sgt i32 %n, 0
|
||||
br i1 %first.itr.check, label %loop, label %exit
|
||||
|
||||
loop:
|
||||
%idx = phi i32 [ 0, %entry ] , [ %idx.next, %in.bounds ]
|
||||
%idx.next = add i32 %idx, 1
|
||||
%abc = icmp slt i32 %idx, %len
|
||||
br i1 %abc, label %in.bounds, label %out.of.bounds, !prof !1
|
||||
|
||||
in.bounds:
|
||||
%addr = getelementptr i32, i32* %arr, i32 %idx
|
||||
store i32 0, i32* %addr
|
||||
%next = icmp slt i32 %idx.next, %n
|
||||
br i1 %next, label %loop, label %exit
|
||||
|
||||
out.of.bounds:
|
||||
ret void
|
||||
|
||||
exit:
|
||||
ret void
|
||||
}
|
||||
|
||||
!0 = !{i32 0, i32 2147483647}
|
||||
!1 = !{!"branch_weights", i32 1, i32 64}
|
Loading…
Reference in New Issue