[PATCH] D112637: [SCEVExpander] Be more conservative about poison flags when reusing instructions

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 27 10:45:33 PDT 2021


reames created this revision.
reames added reviewers: nikic, mkazantsev, fhahn.
Herald added subscribers: javed.absar, bollu, hiraditya, nemanjai, mcrosier.
reames requested review of this revision.
Herald added a project: LLVM.

Noticed while reviewing D112389 <https://reviews.llvm.org/D112389>.  Unfortunately, I don't have a good test case, just noticed during code review.

The basic problem we have is that we're trying to reuse an instruction which is mapped to some SCEV.  Since we can have multiple such instructions (potentially with different flags), this is analogous to our need to drop flags when performing CSE.  A trivial implementation would simply drop flags on any instruction we decided to reuse, and that would be correct.

However, we tackle the problem a bit differently.  If we can prove that *all* instructions which map to the SCEV could validly have the flags on the instruction, then we can simply reuse I with those flags in place.  The proof of all instructions depends on the defining scope notion and how we define what flags are valid on a SCEV to start with.

In practice, this fixes two conceptual problems with the previous code: 1) a binop could have been canonicalized into a form where there was no binop left, or 2) the inbounds GEP case which was simply unhandled.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112637

Files:
  llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
  llvm/test/CodeGen/PowerPC/common-chain.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112637.382718.patch
Type: text/x-patch
Size: 12021 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211027/bab7f3ef/attachment.bin>


More information about the llvm-commits mailing list