This is an archive of the discontinued LLVM Phabricator instance.

[SCEV] Clarify inference in isAddRecNeverPoison()
ClosedPublic

Authored by nikic on Apr 18 2023, 6:33 AM.

Details

Summary

The justification in isAddRecNeverPoison() no longer applies, as it dates back to a time where LLVM had an unconditional forward progress guarantee. However, we also no longer need it, because we can exploit branch on poison UB instead.

For a single exit loop (without abnormal exits) we know that all instructions dominating the exit will be executed, so if any of them trigger UB on poison that means that addrec is not poison.

This is slightly stronger than the previous code, because a) we don't need the exit to also be the latch and b) we don't need the value to be used in the exit branch in particular, any UB-producing instruction is fine.

I don't expect much practical impact from this change, this is mainly to clarify the reasoning behind this logic.

Diff Detail

Event Timeline

nikic created this revision.Apr 18 2023, 6:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2023, 6:33 AM
nikic requested review of this revision.Apr 18 2023, 6:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2023, 6:33 AM
mkazantsev accepted this revision.Apr 21 2023, 4:50 AM
mkazantsev added inline comments.
llvm/lib/Analysis/ScalarEvolution.cpp
7292–7299

Skip users that are not in the same loop just to save some time?

This revision is now accepted and ready to land.Apr 21 2023, 4:50 AM
This revision was landed with ongoing or failed builds.Apr 21 2023, 6:31 AM
This revision was automatically updated to reflect the committed changes.
nikic marked an inline comment as done.