[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
Sun Dec 18 04:20:30 PST 2022


fhahn updated this revision to Diff 483809.
fhahn marked an inline comment as done.
fhahn added a comment.

rebase after update to D135017 <https://reviews.llvm.org/D135017>


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
@@ -481,10 +481,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() > BestVF.getKnownMinValue() * BestUF)
+  const SCEV *C =
+      SE.getConstant(ExitCount->getType(), BestVF.getKnownMinValue() * BestUF);
+  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.483809.patch
Type: text/x-patch
Size: 1755 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221218/62a984aa/attachment.bin>


More information about the llvm-commits mailing list