[PATCH] D155459: [AArch64] Change the cost of vector insert/extract to 2

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 17 06:50:02 PDT 2023


dmgreen created this revision.
dmgreen added reviewers: SjoerdMeijer, samtebbs, fhahn, t.p.northover, Allen, peterwaller-arm.
Herald added subscribers: StephenFan, hiraditya, kristof.beyls.
Herald added a project: All.
dmgreen requested review of this revision.
Herald added a subscriber: wangpc.
Herald added a project: LLVM.

The cost of vector instructions has always been high under AArch64, in order to add a high cost for inserts/extracts, shuffles and scalarization. This is a conservative approach to limit the scope of "unusual" SLP vectorization where the codegen ends up being quite poor, but has always been higher than the "correct" costs would be for any specific core.

This relaxes that, reducing the vector insert/extract cost from 3 to 2. The ScalarizationOverhead is also overridden for integer vector at the same time, to remove the effect of lane 0 being considered free for integer vectors (something that should only be true for float when scalarizing).

The lower insert/extract cost will reduce the cost of insert, extracts, shuffling and scalarization. The adjustments of ScalaizationOverhead will increase the cost on integer, especially for small vectors. The end result will be lower cost for float and long-integer types, some higher cost for some smaller vectors. This, along with the raw insert/extract cost being lower, will generally mean more vectorization from the Loop and SLP vectorizer.

We may learn to regret this, as that vectorization is not always profitable. In all the benchmarking I have done this is generally an improvement in the overall performance, and I've attempted to address the places where it wasn't with other costmodel adjustments.


https://reviews.llvm.org/D155459

Files:
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
  llvm/test/Analysis/CostModel/AArch64/arith-fp.ll
  llvm/test/Analysis/CostModel/AArch64/arith-overflow.ll
  llvm/test/Analysis/CostModel/AArch64/bswap.ll
  llvm/test/Analysis/CostModel/AArch64/cast.ll
  llvm/test/Analysis/CostModel/AArch64/cmp.ll
  llvm/test/Analysis/CostModel/AArch64/ctlz.ll
  llvm/test/Analysis/CostModel/AArch64/cttz.ll
  llvm/test/Analysis/CostModel/AArch64/div.ll
  llvm/test/Analysis/CostModel/AArch64/fptoi_sat.ll
  llvm/test/Analysis/CostModel/AArch64/free-widening-casts.ll
  llvm/test/Analysis/CostModel/AArch64/fshl.ll
  llvm/test/Analysis/CostModel/AArch64/fshr.ll
  llvm/test/Analysis/CostModel/AArch64/getIntrinsicInstrCost-vector-reverse.ll
  llvm/test/Analysis/CostModel/AArch64/insert-extract.ll
  llvm/test/Analysis/CostModel/AArch64/masked_ldst.ll
  llvm/test/Analysis/CostModel/AArch64/mem-op-cost-model.ll
  llvm/test/Analysis/CostModel/AArch64/min-max.ll
  llvm/test/Analysis/CostModel/AArch64/reduce-fadd.ll
  llvm/test/Analysis/CostModel/AArch64/reduce-minmax.ll
  llvm/test/Analysis/CostModel/AArch64/rem.ll
  llvm/test/Analysis/CostModel/AArch64/shuffle-load.ll
  llvm/test/Analysis/CostModel/AArch64/shuffle-other.ll
  llvm/test/Analysis/CostModel/AArch64/shuffle-select.ll
  llvm/test/Analysis/CostModel/AArch64/sve-insert-extract.ll
  llvm/test/Analysis/CostModel/AArch64/sve-intrinsics.ll
  llvm/test/Analysis/CostModel/AArch64/vector-select.ll
  llvm/test/Transforms/LoopVectorize/AArch64/aarch64-predication.ll
  llvm/test/Transforms/LoopVectorize/AArch64/interleaved-vs-scalar.ll
  llvm/test/Transforms/LoopVectorize/AArch64/interleaved_cost.ll
  llvm/test/Transforms/LoopVectorize/AArch64/masked-op-cost.ll
  llvm/test/Transforms/LoopVectorize/AArch64/predication_costs.ll
  llvm/test/Transforms/LoopVectorize/AArch64/strict-fadd-cost.ll
  llvm/test/Transforms/LoopVectorize/AArch64/unsafe-vf-hint-remark.ll
  llvm/test/Transforms/LowerMatrixIntrinsics/dot-product-float.ll
  llvm/test/Transforms/SLPVectorizer/AArch64/ext-trunc.ll
  llvm/test/Transforms/SLPVectorizer/AArch64/gather-cost.ll
  llvm/test/Transforms/SLPVectorizer/AArch64/getelementptr.ll
  llvm/test/Transforms/SLPVectorizer/AArch64/landing_pad.ll
  llvm/test/Transforms/SLPVectorizer/AArch64/matmul.ll
  llvm/test/Transforms/SLPVectorizer/AArch64/memory-runtime-checks.ll
  llvm/test/Transforms/SLPVectorizer/AArch64/multiple_reduction.ll
  llvm/test/Transforms/SLPVectorizer/AArch64/slp-fma-loss.ll
  llvm/test/Transforms/VectorCombine/AArch64/load-extractelement-scalarization.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155459.540925.patch
Type: text/x-patch
Size: 442163 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230717/f7e5d64e/attachment-0001.bin>


More information about the llvm-commits mailing list