[PATCH] D125301: [LoopVectorize] Add option to use active lane mask for loop control flow

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 6 05:48:31 PDT 2022


david-arm added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/VPlan.cpp:941
+      (Term->getOpcode() == VPInstruction::BranchOnCount ||
+       Term->getOpcode() == VPInstruction::BranchOnCond) &&
       isa<ConstantInt>(TripCountV)) {
----------------
fhahn wrote:
> Is this covered by a test? The comment and logic above applies specifically to `BranchOnCount`. It is not entirely clear to me  that it would be safe for any `BranchOnCond`?
It is covered by sve-low-trip-count.ll, since we create BranchOnCond using the active lane mask. I did this after you suggested in earlier review comments to use BranchOnCond instead of BranchOnActiveLaneMask because we don't want to regress for low trip counts. We also don't have access to the TripCount in addCanonicalIVRecipes, so I can't use that to determine what type of Branch instruction to use.

It's a shame that there is no easy way to add a flag to the VPInstruction to mark it as safe for optimisation here. For example, it would be nice to do something like

  (Term->getOpcode() == VPInstruction::BranchOnCount ||
   (Term->getOpcode() == VPInstruction::BranchOnCond && Term->isBranchSafeToOptimise())



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

https://reviews.llvm.org/D125301



More information about the llvm-commits mailing list