[PATCH] D106580: [LoopFlatten] Use SCEV and Loop APIs to identify increment and trip count

Sjoerd Meijer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 26 00:10:39 PDT 2021


SjoerdMeijer added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/LoopFlatten.cpp:175
+      SE->getTripCountFromExitCount(SE->getBackedgeTakenCount(L));
+  if (!(SE->getSCEV(TripCount) == SCEVTripCount) && !IsWidened) {
+    LLVM_DEBUG(dbgs() << "Could not find valid trip count\n");
----------------
Can this be `!=`?


================
Comment at: llvm/lib/Transforms/Scalar/LoopFlatten.cpp:178
     return false;
   }
   IterationInstructions.insert(Increment);
----------------
We are not doing this sanity check when the IV is widened.
Can we also check this case and do something like this?

  ExtTC = Tripcount->getOperand(0);
  if (!isa<ZExt>(ExtTC) || !isa<SExt>(ExtTC) ||
      SE->getSCEV(ExtTC) != SCEVTripCount ) {
    LLVM_DEBUG(dbgs() << "Could not find valid extended trip count\n");
    return false;
  }
    


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

https://reviews.llvm.org/D106580



More information about the llvm-commits mailing list