[PATCH] D51186: [x86] turn insertelement into undef with variable index into splat

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 23 14:22:44 PDT 2018


spatel created this revision.
spatel added reviewers: efriedma, craig.topper, RKSimon.
Herald added subscribers: kristof.beyls, tpr, mcrosier.
Herald added a reviewer: javed.absar.

I noticed this along with the patterns in https://reviews.llvm.org/D51125, but when the index is variable, we don't convert insertelement into a build_vector.

For x86, that means these get expanded at legalization time into the loading/spilling code that we see in the tests. I think it's always better to avoid going to memory on these, and we get the optimal 'broadcast' if it's available.

I suspect other targets may want to look at enabling the hook. AArch64 and AMDGPU have regression tests that would be affected (although I did not check what would happen in those cases). In the most basic cases shown here, AArch64 would do much better with a splat.


https://reviews.llvm.org/D51186

Files:
  include/llvm/CodeGen/TargetLowering.h
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  lib/Target/X86/X86ISelLowering.cpp
  lib/Target/X86/X86ISelLowering.h
  test/CodeGen/X86/insertelement-var-index.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51186.162263.patch
Type: text/x-patch
Size: 25653 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180823/56cf5566/attachment.bin>


More information about the llvm-commits mailing list