[PATCH] D107806: [LoopFlatten] Fix assertion failure

Sjoerd Meijer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 11 05:26:59 PDT 2021


SjoerdMeijer added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/LoopFlatten.cpp:179
+  const SCEV *SCEVRHS = SE->getSCEV(RHS);
+  if (SCEVRHS != SCEVTripCount) {
+    ConstantInt *ConstantRHS = dyn_cast<ConstantInt>(RHS);
----------------
This has become quite complicated logic. I am wondering if we can handle the simple case first to reduce indentation and improve readability:

  if (SCEVRHS == SCEVTripCount)
    return setLoopComponents(RHS, Increment);

where `setLoopComponents` is a new helper that includes the code at lines 229 - 233 and sets `TripCount`.






================
Comment at: llvm/lib/Transforms/Scalar/LoopFlatten.cpp:194
+        }
+      } else {
+        BackedgeTCExt = nullptr;
----------------
Remove this `else` and just initialise `BackedgeTCExt` above?

  const SCEV *BackedgeTCExt = nullptr;


================
Comment at: llvm/lib/Transforms/Scalar/LoopFlatten.cpp:229
   }
   IterationInstructions.insert(Increment);
   LLVM_DEBUG(dbgs() << "Found increment: "; Increment->dump());
----------------
Then we can replace next lines with:

   return setLoopComponents(RHS, Increment);


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107806/new/

https://reviews.llvm.org/D107806



More information about the llvm-commits mailing list