This is an archive of the discontinued LLVM Phabricator instance.

[GuardWidening] Widen very likely non-taken br instructions
ClosedPublic

Authored by mkazantsev on Jul 31 2018, 12:30 AM.

Details

Summary

This is a second part of D49974 that handles widening of conditional branches that
have very likely false branch.

Diff Detail

Repository
rL LLVM

Event Timeline

reames requested changes to this revision.Aug 3 2018, 10:00 AM
reames added inline comments.
lib/Transforms/Scalar/GuardWidening.cpp
526 ↗(On Diff #158975)

You should be able to handle this case by simply inverting Pred1 if InvertCondition is true.

This revision now requires changes to proceed.Aug 3 2018, 10:00 AM
mkazantsev updated this revision to Diff 159440.Aug 6 2018, 6:42 PM
mkazantsev marked an inline comment as done.

Removed one of TODO limitations, added corresponding tests.

reames accepted this revision.Aug 10 2018, 1:50 PM

LGTM w/one required change before commit. I'm assuming the fix is 2-3 lines (basically adding a param pass through), if it's anything other than that, please come back for another round of review.

lib/Transforms/Scalar/GuardWidening.cpp
391 ↗(On Diff #159440)

It looks like you forgot to invert the condition when checking profit. Should be an easy fix, but add a test case which shows the problem too.

This revision is now accepted and ready to land.Aug 10 2018, 1:50 PM
mkazantsev added inline comments.Aug 12 2018, 8:26 PM
lib/Transforms/Scalar/GuardWidening.cpp
391 ↗(On Diff #159440)

I'm not sure what do you mean. This function only checks if we are hoisting out of loop or not and availability of condition at candidate's point. How can inversion of condition affect that?

mkazantsev added inline comments.Aug 12 2018, 10:06 PM
lib/Transforms/Scalar/GuardWidening.cpp
391 ↗(On Diff #159440)

Just realized that isWideningCondProfitable does a really ugly thing inside and may end up creating instructions. I will propagate the inversion flag there, but it must be rework in the follow-up.

This revision was automatically updated to reflect the committed changes.