[PATCH] D32827: [AArch64] Correct lane zero optimization in insert/extract costs

Matthew Simpson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 3 13:14:26 PDT 2017


mssimpso created this revision.
Herald added subscribers: rengolin, aemerson.

In the TTI calculation of vector insert and extract costs, we have an optimization that returns a cost of zero if we are inserting into or extracting from vector lane zero. All other inserts and extracts cost the base amount specified by the sub-target. However, the lane zero optimization only makes sense for floating-point types (i.e., within-class moves). For integer types, we should incur a cost for moving data from vector to general purpose registers, even for lane zero.

This patch modifies the lane zero optimization so that it applies only to floating-point types. Additionally, we now fall back to the base TTI implementation for all other floating-point inserts and extracts. The existing sub-target specified insert/extract costs are used only for the cross-class moves, which I think was probably the original intent. Since the existing code looks like a bug to me, I checked the X86 target, and it implements something similar to what is in this patch.

I've added a new cost model test case in Analysis/CostModel/AArch64/inserts-extracts.ll. All other test case changes are trivial (e.g., they lower the SLP threshold to ensure tests still vectorize).


https://reviews.llvm.org/D32827

Files:
  lib/Target/AArch64/AArch64TargetTransformInfo.cpp
  test/Analysis/CostModel/AArch64/bswap.ll
  test/Analysis/CostModel/AArch64/falkor.ll
  test/Analysis/CostModel/AArch64/inserts-extracts.ll
  test/Analysis/CostModel/AArch64/kryo.ll
  test/Transforms/LoopVectorize/AArch64/aarch64-predication.ll
  test/Transforms/LoopVectorize/AArch64/interleaved-vs-scalar.ll
  test/Transforms/LoopVectorize/AArch64/interleaved_cost.ll
  test/Transforms/LoopVectorize/AArch64/predication_costs.ll
  test/Transforms/SLPVectorizer/AArch64/gather-root.ll
  test/Transforms/SLPVectorizer/AArch64/getelementptr.ll
  test/Transforms/SLPVectorizer/AArch64/horizontal.ll
  test/Transforms/SLPVectorizer/AArch64/sdiv-pow2.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32827.97719.patch
Type: text/x-patch
Size: 19401 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170503/87b166a1/attachment.bin>


More information about the llvm-commits mailing list