[PATCH] D152366: [LoopVectorize] Allow inner loop runtime checks to be hoisted above an outer loop

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 19 10:29:00 PDT 2023


fhahn added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/LoopUtils.cpp:1669
+        OuterExitCount->getType()->isIntegerTy()) {
+      const SCEV *NewHigh = cast<SCEVAddRecExpr>(High)->evaluateAtIteration(
+          OuterExitCount, *Exp.getSE());
----------------
Do we need to check if the AddRecs here don't wrap? If it would wrap, could NewHigh < NewLow?


================
Comment at: llvm/lib/Transforms/Utils/LoopUtils.cpp:1650
+      isa<SCEVAddRecExpr>(High) && isa<SCEVAddRecExpr>(Low) &&
+      cast<SCEVAddRecExpr>(Low)->getLoop() == TheLoop->getParentLoop()) {
+    const Loop *OuterLoop = TheLoop->getParentLoop();
----------------
paulwalker-arm wrote:
> Given you evaluate `High` using the outer loop's exit count shouldn't you also check the following?
> ```
> cast<SCEVAddRecExpr>(High)->getLoop() == TheLoop->getParentLoop()
> ```
Could you add a test case for this case?


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

https://reviews.llvm.org/D152366



More information about the llvm-commits mailing list