[PATCH] D148633: [SCEV] Clarify inference in isAddRecNeverPoison()

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 18 06:33:56 PDT 2023


nikic created this revision.
nikic added reviewers: reames, mkazantsev, fhahn, efriedma.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


https://reviews.llvm.org/D148633

Files:
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148633.514631.patch
Type: text/x-patch
Size: 8109 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230418/806fccfb/attachment.bin>


More information about the llvm-commits mailing list