[PATCH] D133017: [LV] Use SCEV to check if the trip count <= VF * UF.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 24 10:39:48 PST 2022


fhahn marked 2 inline comments as done.
fhahn added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp:483
       Plan.getCanonicalIV()->getStartValue()->getLiveInIRValue()->getType();
   const SCEV *ExitCount = createTripCountSCEV(IdxTy, PSE);
   ScalarEvolution &SE = *PSE.getSE();
----------------
Ayal wrote:
> Thought: create vector trip count SCEV, once VF and UF are set; use it to create vector trip count Value, and also to check if it is known to be less than or equal to 1?
Will do as follow-up! Would be good to integrate it once the loop skeleton is also created in VPlan.


================
Comment at: llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp:469
+  if (ExitCount->isZero() ||
+      !SE.isKnownPredicate(CmpInst::ICMP_ULE, ExitCount, C))
     return;
----------------
Ayal wrote:
> fhahn wrote:
> > Ayal wrote:
> > > Could this be simplified using SE.getSmallConstantMaxTripCount(L)? Or a caching thereof.
> > `SE.getSmallConstantMaxTripCount(L)` only supports the case where the trip count is a constant, while `isKnownPredicate` supports the non-constant case as well.
> Ok. Non-constant case seems a bit extreme, unless tail is folded - vectorizing and unrolling to a known upper bound will otherwise run the original scalar loop whenever its trip count misses the exact upper bound.
Yes, the transform just removes an unneeded branch; deciding whether it is profitable to vectorize with scalar tail will still be done elsewhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133017



More information about the llvm-commits mailing list