[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
Tue May 10 03:40:31 PDT 2022


david-arm created this revision.
david-arm added reviewers: sdesmalen, kmclaughlin, CarolineConcatto, RosieSumpter, fhahn, greened.
Herald added subscribers: rogfer01, zzheng, hiraditya.
Herald added a project: All.
david-arm requested review of this revision.
Herald added subscribers: llvm-commits, vkmr.
Herald added a project: LLVM.

Currently, for vectorised loops that use the get.active.lane.mask
intrinsic we only use the mask for predicated vector operations,
such as masked loads and stores, etc. The loop itself is still
controlled by comparing the canonical induction variable with the
trip count. However, for some targets this is inefficient when it's
cheap to use the mask itself to control the loop.

This patch adds support for using the active lane mask for control
flow by:

1. Generating the active lane mask for the next iteration of the

vector loop, rather than the current one. If there are still any
remaining iterations then at least the first bit of the mask will
be set.

2. Extract the first bit of this mask and use this bit for the

conditional branch.

I did this by creating a new VPActiveLaneMaskPHIRecipe that sets
up the initial PHI values in the vector loop pre-header. I've also
created a new BranchOnActiveLaneMask VPInstruction for the final
instruction in the loop region.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125301

Files:
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
  llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
  llvm/lib/Target/ARM/ARMTargetTransformInfo.h
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/lib/Transforms/Vectorize/VPlan.cpp
  llvm/lib/Transforms/Vectorize/VPlan.h
  llvm/lib/Transforms/Vectorize/VPlanValue.h
  llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
  llvm/test/Transforms/LoopVectorize/AArch64/sve-tail-folding-forced.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-tail-folding-unroll.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-tail-folding.ll
  llvm/test/Transforms/LoopVectorize/AArch64/tail-fold-uniform-memops.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125301.428328.patch
Type: text/x-patch
Size: 119037 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220510/e95715ae/attachment-0001.bin>


More information about the llvm-commits mailing list