[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 Oct 1 12:47:28 PDT 2022


fhahn updated this revision to Diff 464511.
fhahn added a comment.

Rebased on top of D135017 <https://reviews.llvm.org/D135017>, which contains the main refactoring to prepare for this change, which now just changes to use ScalarEvolution::isKnowPredicate.


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
@@ -462,10 +462,11 @@
   Type *IdxTy =
       Plan.getCanonicalIV()->getStartValue()->getLiveInIRValue()->getType();
   const SCEV *ExitCount = createTripCountSCEV(IdxTy, PSE);
-  auto *C = dyn_cast<SCEVConstant>(ExitCount);
   ScalarEvolution &SE = *PSE.getSE();
-  if (!C || ExitCount->isZero() ||
-      C->getAPInt().getZExtValue() > VF.getKnownMinValue() * UF)
+  const SCEV *C =
+      SE.getConstant(ExitCount->getType(), VF.getKnownMinValue() * UF);
+  if (ExitCount->isZero() ||
+      !SE.isKnownPredicate(CmpInst::ICMP_ULE, ExitCount, C))
     return;
 
   LLVMContext &Ctx = SE.getContext();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133017.464511.patch
Type: text/x-patch
Size: 1739 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221001/02f46fce/attachment.bin>


More information about the llvm-commits mailing list