[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:35:32 PST 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9758242046b3: [LV] Use SCEV to check if the trip count <= VF * UF. (authored by fhahn).

Changed prior to commit:
  https://reviews.llvm.org/D133017?vs=485193&id=485205#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133017

Files:
  llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
  llvm/test/Transforms/LoopVectorize/vector-loop-backedge-elimination.ll


Index: llvm/test/Transforms/LoopVectorize/vector-loop-backedge-elimination.ll
===================================================================
--- llvm/test/Transforms/LoopVectorize/vector-loop-backedge-elimination.ll
+++ llvm/test/Transforms/LoopVectorize/vector-loop-backedge-elimination.ll
@@ -11,11 +11,9 @@
 ; VF8UF1:       [[CMP:%.+]] = icmp eq i64 %index.next, %n.vec
 ; VF8UF1-NEXT:  br i1 [[CMP]], label %middle.block, label %vector.body
 ;
-; VF8UF2:       [[CMP:%.+]] = icmp eq i64 %index.next, %n.vec
-; VF8UF2-NEXT:  br i1 [[CMP]], label %middle.block, label %vector.body
+; VF8UF2:       br i1 true, label %middle.block, label %vector.body
 ;
-; VF16UF1:       [[CMP:%.+]] = icmp eq i64 %index.next, %n.vec
-; VF16UF1-NEXT:  br i1 [[CMP]], label %middle.block, label %vector.body
+; VF16UF1:      br i1 true, label %middle.block, label %vector.body
 ;
 entry:
   %and = and i64 %N, 15
Index: llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -482,10 +482,11 @@
   Type *IdxTy =
       Plan.getCanonicalIV()->getStartValue()->getLiveInIRValue()->getType();
   const SCEV *TripCount = createTripCountSCEV(IdxTy, PSE);
-  auto *C = dyn_cast<SCEVConstant>(TripCount);
   ScalarEvolution &SE = *PSE.getSE();
-  if (!C || TripCount->isZero() ||
-      C->getAPInt().getZExtValue() > BestVF.getKnownMinValue() * BestUF)
+  const SCEV *C =
+      SE.getConstant(TripCount->getType(), BestVF.getKnownMinValue() * BestUF);
+  if (TripCount->isZero() ||
+      !SE.isKnownPredicate(CmpInst::ICMP_ULE, TripCount, C))
     return;
 
   LLVMContext &Ctx = SE.getContext();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133017.485205.patch
Type: text/x-patch
Size: 1755 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221224/d6b7d1f4/attachment.bin>


More information about the llvm-commits mailing list