[PATCH] D144375: [SystemZ, SLP] Enable FP horizontal reductions and fix SLP cost computation.

Jonas Paulsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 20 03:38:31 PST 2023


jonpa created this revision.
jonpa added reviewers: uweigand, ABataev.
Herald added subscribers: vporpo, hiraditya.
Herald added a project: All.
jonpa requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead.
Herald added a project: LLVM.

Implement SystemZTTIImpl::getArithmeticReductionCost() and SystemZTTIImpl::getMinMaxReductionCost() for floating point. I ran into some issues with the integer versions so it seemed simplest to do the FP opcodes first.

In order to enable reductions also when the elements are loaded from non-consecutive addresses, SLP needs a small patch for the computation in getGatherCost(). If the target supports it, there is no extra cost for a vector element load. This did not change any existing tests. Given the element load instructions, I think it makes sense to do this.

This gives a nice improvement on f519.lbm_r (with -funsafe-math-optimizations).

fp128 also benefits from this I think, due to the reassociation of the operands. In order to enable it I gave an arbitrary discount by dividing the number of elements with 2 and using that as the cost.

@ABataev : Does the SLP change look good to you?


https://reviews.llvm.org/D144375

Files:
  llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
  llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.h
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  llvm/test/Analysis/CostModel/SystemZ/vector-reductions-fp.ll
  llvm/test/Transforms/SLPVectorizer/SystemZ/reductions-fadd.ll
  llvm/test/Transforms/SLPVectorizer/SystemZ/reductions-fmin-fmax.ll
  llvm/test/Transforms/SLPVectorizer/SystemZ/reductions-fmul.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144375.498785.patch
Type: text/x-patch
Size: 152555 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230220/ae9f18da/attachment-0001.bin>


More information about the llvm-commits mailing list