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

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 6 22:10:37 PDT 2022


fhahn added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/VPlan.cpp:941
+      (Term->getOpcode() == VPInstruction::BranchOnCount ||
+       Term->getOpcode() == VPInstruction::BranchOnCond) &&
       isa<ConstantInt>(TripCountV)) {
----------------
david-arm wrote:
> 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())
> 
Thanks, I don't think a flag is actually needed. IIUC it should be sufficient to check if the operand of the BranchOnCond is fed by the current active lane mask and update the comment?


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

https://reviews.llvm.org/D125301



More information about the llvm-commits mailing list