[PATCH] D84741: [LV][ARM] Allow tail folded reduction selects to remain in the loop

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 28 03:35:21 PDT 2020


dmgreen created this revision.
dmgreen added reviewers: Ayal, SjoerdMeijer, gilr, fhahn.
Herald added subscribers: danielkiss, hiraditya, kristof.beyls.
Herald added a project: LLVM.
dmgreen requested review of this revision.

The normal scheme for tail folding reductions is to use:

  loop:
    p = phi(0, a)
    mask = ...
    x = masked_load(..., mask)
    a = add(x, p)
  s = select(mask, a, p)

This means we need to keep the register p and a alive out of the loop, plus the mask. On a target with predicated operations we can instead generate the phi as `p = phi(0, s)`. This ensures the select in the loop and we can fold `select(m, add(a, b), c)` to something like a `vaddt c, a, b` using the m predicate. This in turn allows us to tail predicate the entire loop.


https://reviews.llvm.org/D84741

Files:
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
  llvm/lib/Target/ARM/ARMTargetTransformInfo.h
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Transforms/LoopVectorize/ARM/reduction-predselect.ll
  llvm/test/Transforms/LoopVectorize/ARM/tail-folding-not-allowed.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84741.281157.patch
Type: text/x-patch
Size: 39561 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200728/ea39f1ae/attachment-0001.bin>


More information about the llvm-commits mailing list