This is an archive of the discontinued LLVM Phabricator instance.

[IRCE] Use the same min runtime iteration threshold for BPI and BFI checks
ClosedPublic

Authored by skatkov on Nov 10 2020, 8:48 PM.

Details

Summary

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.

Diff Detail

Event Timeline

skatkov created this revision.Nov 10 2020, 8:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 10 2020, 8:48 PM
skatkov requested review of this revision.Nov 10 2020, 8:48 PM

It looks like the threshold 10 you are referring is coming from some option. Can we use the same option in both places instead?

It looks like the threshold 10 you are referring is coming from some option. Can we use the same option in both places instead?

you mean to combine
static cl::opt<int> MaxExitProbReciprocal("irce-max-exit-prob-reciprocal",

cl::Hidden, cl::init(10));

and
static cl::opt<unsigned> MinRuntimeIterations("min-runtime-iterations",

cl::Hidden, cl::init(10));

into one option?
Are you ok with the name min-runtime-iterations?

Yes, it's what I mean. This name would be fine.

skatkov updated this revision to Diff 304747.Nov 12 2020, 1:40 AM
skatkov retitled this revision from [IRCE] Increase min runtime iteration threshold to [IRCE] Use the same min runtime iteration threshold for BPI and BFI checks.
skatkov edited the summary of this revision. (Show Details)
mkazantsev accepted this revision.Nov 13 2020, 12:54 AM

LGTM, thanks!

llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
115–116

Please rename into irce-min-runtime-itetarions

This revision is now accepted and ready to land.Nov 13 2020, 12:54 AM