This is an archive of the discontinued LLVM Phabricator instance.

Teach IRCE to look at branch weights when recognizing range checks
ClosedPublic

Authored by sanjoy on Jan 26 2015, 10:21 PM.

Details

Summary

Splitting a loop to make range checks redundant is profitable only if the range check "never" fails. Make this fact a part of recognizing a range check -- a branch is a range check only if it is expected to pass (via branch_weights metadata).

Diff Detail

Event Timeline

sanjoy updated this revision to Diff 18796.Jan 26 2015, 10:21 PM
sanjoy retitled this revision from to Teach IRCE to look at branch weights when recognizing range checks.
sanjoy updated this object.
sanjoy edited the test plan for this revision. (Show Details)
sanjoy added reviewers: reames, hfinkel.
sanjoy added a subscriber: Unknown Object (MLST).
hfinkel added inline comments.Jan 27 2015, 6:13 AM
lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
361

Please don't access the branch_weights metadata directly. Use the BranchProbabilityInfo analysis (which also includes some useful static heuristics).

sanjoy updated this revision to Diff 18845.Jan 27 2015, 12:56 PM

Address Hal's comment and use BranchProbabilityInfo instead of manually parsing branch_weights metadata.

hfinkel accepted this revision.Jan 27 2015, 1:14 PM
hfinkel edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Jan 27 2015, 1:14 PM
This revision was automatically updated to reflect the committed changes.