[PATCH] D135017: [LV] Move exit cond simplification to separate transform.

Ayal Zaks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 2 07:32:28 PDT 2022


Ayal added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp:464
+      Plan.getCanonicalIV()->getStartValue()->getLiveInIRValue()->getType();
+  const SCEV *ExitCount = createTripCountSCEV(IdxTy, PSE);
+  auto *C = dyn_cast<SCEVConstant>(ExitCount);
----------------
TripCountV indeed hasn't been created yet, but perhaps there's a simpler way to check this condition, e.g., by checking if PSE.getBackedgeCount() is a constant greater than VF*UF-1, instead of incrementing it by 1 of type IdxTy; or trying to call SE.getSmallConstantTripCount(L); or recording it in VPlan, possibly in CanonicalIV recipe.


================
Comment at: llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp:474
+      new VPInstruction(VPInstruction::BranchOnCond,
+                        {Plan.getOrAddExternalDef(ConstantInt::getTrue(Ctx))});
+  Term->eraseFromParent();
----------------
Worth an unconditional branch VPInstruction instead of the effort to generate a redundant True? Can be fixed independent of this patch, which is working a bit harder to generate it.


================
Comment at: llvm/lib/Transforms/Vectorize/VPlanTransforms.h:66
   static void removeRedundantExpandSCEVRecipes(VPlan &Plan);
+
+  static void optimizeForConcreteVFAndUF(VPlan &Plan, ElementCount VF,
----------------
Missing documentation.


================
Comment at: llvm/test/Transforms/LoopVectorize/lcssa-crashes.ll:16
 ; CHECK-NEXT:    [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4
-; CHECK-NEXT:    br i1 true, label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
+; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq i64 [[INDEX_NEXT]], 0
+; CHECK-NEXT:    br i1 [[TMP1]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
----------------
Is this a regression from previously folding the conditional branch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135017



More information about the llvm-commits mailing list