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

Ayal Zaks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 6 02:47:50 PDT 2022


Ayal added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/VPlan.cpp:608
+        SE.getConstant(TCS->getType(), State.VF.getKnownMinValue() * State.UF);
+    if (SE.isKnownViaNonRecursiveReasoning(CmpInst::ICMP_ULE, TCS, C)) {
       auto *BOC =
----------------
fhahn wrote:
> reames wrote:
> > Please don't change the SCEV interface for this.  Just use isKnownPredicate.  You don't care if the reasoning is recursive or not.  
> The issue here is that we would need to limit the reasoning to methods that don’t try to look at the current IR, just at the SCEV expression, because the IR is in incomplete/partially modified state.
> 
> Using non-recursive reasoning is a proxy for that, but I’m not sure if it provides the required guarantees in all cases.
> 
> The alternative would be to compute the property before we start modifying the CFG, like we do for trip count expansion.
Analyzing and optimizing VPlan should ideally take place as VPlan2VPlan and reflected in VPlan itself before starting/preparing to execute it - at which time the IR is in incomplete/partially modified state. This case of optimizing away the latch branch for single iteration loops depends on UF which VPlan is currently agnostic to and encounters only when executing. How about cloning VPlans (also) according to which UF*VF's result in a single iteration (upto reasonable UF values - computeMaxUF()?), updating the default "UF>=1" in VPlan names and extending getBestPlanFor() to pass both VF and UF? That may admittedly require splitting ranges currently serving multiple VF's.


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