aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopVersioning.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2022-09-23 11:53:29 +0100
committerFlorian Hahn <flo@fhahn.com>2022-09-23 11:53:29 +0100
commit623c4a7a55f716b96070a5c2f83fe0096cb38d38 (patch)
treee4c627a787a80bc4e75854ed1e0577d1a1b6e867 /llvm/lib/Transforms/Utils/LoopVersioning.cpp
parent17167005d532dce35ade3a47a0403ffaa7fff6ff (diff)
downloadllvm-623c4a7a55f716b96070a5c2f83fe0096cb38d38.zip
llvm-623c4a7a55f716b96070a5c2f83fe0096cb38d38.tar.gz
llvm-623c4a7a55f716b96070a5c2f83fe0096cb38d38.tar.bz2
[LoopVersioning] Invalidate SCEV for phi if new values are added.
After 20d798bd47ec5191d, SCEV looks through PHIs with a single incoming value. This means adding a new incoming value may change the SCEV for a phi. Add missing invalidation when an existing PHI is reused during LoopVersioning. New incoming values will be added later from the versioned loop. Similar issues have been fixed by also adding missing invalidation. Fixes #57825. Note that the test case unfortunately requires running loop-vectorize followed by loop-load-elimination, which does the actual versioning. I don't think it is possible to reproduce the failure without that combination.
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopVersioning.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopVersioning.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopVersioning.cpp b/llvm/lib/Transforms/Utils/LoopVersioning.cpp
index 97f2952..6309eed 100644
--- a/llvm/lib/Transforms/Utils/LoopVersioning.cpp
+++ b/llvm/lib/Transforms/Utils/LoopVersioning.cpp
@@ -137,8 +137,10 @@ void LoopVersioning::addPHINodes(
// See if we have a single-operand PHI with the value defined by the
// original loop.
for (auto I = PHIBlock->begin(); (PN = dyn_cast<PHINode>(I)); ++I) {
- if (PN->getIncomingValue(0) == Inst)
+ if (PN->getIncomingValue(0) == Inst) {
+ SE->forgetValue(PN);
break;
+ }
}
// If not create it.
if (!PN) {