[PATCH] D129501: Redefine get.active.lane.mask to allow a more scalar lowering

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 11 10:12:38 PDT 2022


reames created this revision.
reames added reviewers: craig.topper, frasercrmck, david-arm.
Herald added subscribers: luke957, StephenFan, jdoerfert, luismarques, apazos, sameer.abuasal, s.egerton, dmgreen, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, bollu, simoncook, johnrusso, rbar, asb, hiraditya, kristof.beyls, arichardson, mcrosier.
Herald added a project: All.
reames requested review of this revision.
Herald added subscribers: pcwang-thead, MaskRay.
Herald added a project: LLVM.

The meat of this patch is a change to lowering of llvm.get.active.lane.mask to first compute the remaining lanes which need to be active in the scalar domain, and then use a single vector comparison.  This replaces the existing lowering which uses a vector saturating add, and then a comparison.  (For discussion, I'm ignoring the splats since they generally get folded into using instructions.)  This results in a significant codegen improvement for RISCV, and while I'm not an expert in AArch64, the result appears profitable to me - confirmation desired.

To do this, I have the change the specified semantics of the intrinsic slightly.  Specifically, I need the assumption that trip count is unsigned greater than or equal to the base index to avoid needing a saturating subtract in the scalar domain.  (I tried using the saturating subtract, and practical codegen results were poor.)  As far as I can tell, the revised semantics is consistent with actual usage.

As an aside, I am wondering if we need this intrinsic at all.  The lowering chosen here could be used by the vectorizer directly, and the AArch64 whillelo pattern match for the EVL form would seem straight forward.  Maybe we'd have trouble folding the SUB back in, but has anyone played with this?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129501

Files:
  llvm/docs/LangRef.rst
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/test/CodeGen/AArch64/active_lane_mask.ll
  llvm/test/CodeGen/RISCV/rvv/active_lane_mask.ll
  llvm/test/CodeGen/Thumb2/LowOverheadLoops/constbound.ll
  llvm/test/CodeGen/Thumb2/active_lane_mask.ll
  llvm/test/CodeGen/Thumb2/mve-blockplacement.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129501.443678.patch
Type: text/x-patch
Size: 49733 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220711/36849894/attachment-0001.bin>


More information about the llvm-commits mailing list