This is an archive of the discontinued LLVM Phabricator instance.

[SCEV] If max BTC is zero, then so is the exact BTC [2 of 2]
ClosedPublic

Authored by reames on Aug 31 2021, 12:09 PM.

Details

Summary

This extends D108921 into a generic rule applied to constructing ExitLimits along all paths. The remaining paths (primarily howFarToZero) don't have the same reasoning about UB sensitivity as the howManyLessThan ones did. Instead, the remain cause for max counts being more precise than exact counts is that we apply context sensitive loop guards on the max path, and not on the exact path. That choice is mildly suspect, but out of scope of this patch.

The MVETailPredication.cpp change deserves a bit of explanation. We were previously figuring out that two SCEVs happened to be equal because the happened to be identical. When we optimized one with context sensitive information, but not the other, we lost the ability to prove them equal. So, cover this case by subtracting and then applying loop guards again. Without this, we see changes in test/CodeGen/Thumb2/mve-blockplacement.ll

Diff Detail

Event Timeline

reames created this revision.Aug 31 2021, 12:09 PM
reames requested review of this revision.Aug 31 2021, 12:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2021, 12:09 PM
nikic added inline comments.Aug 31 2021, 1:08 PM
llvm/lib/Target/ARM/MVETailPredication.cpp
305

Any chance evaluating an EQ predicate with one of our context sensitive functions (like isLoopEntryGuardedBy) would also work here? Calling applyLoopGuards() here is rather tightly coupled to SCEV implementation details.

reames added inline comments.Sep 1 2021, 9:04 AM
llvm/lib/Target/ARM/MVETailPredication.cpp
305

I don't believe we can here without changing the cases this can and can't handle more than I'm comfortable with. I don't understand this code - the comments appears to be out of sync with what it actually does - so I'd strongly prefer to keep it as close to the original structure as possible.

nikic accepted this revision.Sep 1 2021, 9:39 AM
nikic added a subscriber: SjoerdMeijer.

LGTM

llvm/lib/Target/ARM/MVETailPredication.cpp
305

Okay, let's land this as-is. But maybe @dmgreen or @SjoerdMeijer can take a look at this code and check whether it's possible to avoid doing this.

This revision is now accepted and ready to land.Sep 1 2021, 9:39 AM
This revision was landed with ongoing or failed builds.Sep 1 2021, 11:51 AM
This revision was automatically updated to reflect the committed changes.