[llvm] [SCEV] Do not allow refinement in the rewriting of BEValue (PR #117152)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 29 08:07:16 PST 2024
================
@@ -5933,18 +5925,22 @@ const SCEV *ScalarEvolution::createAddRecFromPHI(PHINode *PN) {
// We can generalize this saying that i is the shifted value of BEValue
// by one iteration:
// PHI(f(0), f({1,+,1})) --> f({0,+,1})
- const SCEV *Shifted = SCEVShiftRewriter::rewrite(BEValue, L, *this);
- const SCEV *Start = SCEVInitRewriter::rewrite(Shifted, L, *this, false);
- if (Shifted != getCouldNotCompute() &&
- Start != getCouldNotCompute()) {
- const SCEV *StartVal = getSCEV(StartValueV);
- if (Start == StartVal) {
- // Okay, for the entire analysis of this edge we assumed the PHI
- // to be symbolic. We now need to go back and purge all of the
- // entries for the scalars that use the symbolic expression.
- forgetMemoizedResults(SymbolicName);
- insertValueToMap(PN, Shifted);
- return Shifted;
+
+ // Do not allow refinement in rewriting of BEValue.
+ if (isGuaranteedNotToCauseUB(BEValue) &&
+ isGuaranteedNotToBePoison(BEValue)) {
----------------
nikic wrote:
```suggestion
impliesPoisoin(BEValue. StartVal)) {
```
I think something like that could avoid most of the test changes? The problem is that we often have something like `phi(%x, {%x,+,1})`, which is unproblematic here but will be rejected by a plain poison check.
https://github.com/llvm/llvm-project/pull/117152
More information about the llvm-commits
mailing list