[llvm] LoopLoadElim: don't version single-iteration loops (PR #97599)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 28 06:59:19 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()) {
----------------
fhahn wrote:

Shouldn't this bail out instead of just skipping versioning?

I think the code below assumes versioning happened and it may be required for correctness. If we don't version, we would perform LLE on a single iteration loop without performing the required versioning?

https://github.com/llvm/llvm-project/pull/97599


More information about the llvm-commits mailing list