[llvm] LoopLoadElim: don't version single-iteration loops (PR #97599)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 28 09:39:24 PDT 2024
================
@@ -598,10 +598,11 @@ class LoadEliminationForLoop {
}
// Point of no-return, start the transformation. First, version the loop
- // if necessary.
-
- LoopVersioning LV(LAI, Checks, L, LI, DT, PSE.getSE());
- LV.versionLoop();
+ // if it's not a single-iteration loop.
+ if (!PSE.getBackedgeTakenCount()->isOne()) {
----------------
artagnon wrote:
Actually, that's a good point: while I agree that versioning is required in the general case for correctness, I'm not sure if versioning a single-iteration loop is required for correctness. Doesn't versioning, after all, create a version of the loop that is guaranteed to execute once? If the loop executes just once anyway, will the transformed loop possibly not execute after LLE? I'm confused because the test I included seems to be a correct transformation: is this just incidental?
https://github.com/llvm/llvm-project/pull/97599
More information about the llvm-commits
mailing list