[PATCH] D79886: [DAGCombiner] try to move splat after binop with splat constant

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 13 10:50:22 PDT 2020


spatel created this revision.
spatel added reviewers: craig.topper, RKSimon, efriedma.
Herald added subscribers: hiraditya, kristof.beyls, mcrosier.
Herald added a project: LLVM.

binop (splat X), (splat C) --> splat (binop X, C)
binop (splat C), (splat X) --> splat (binop C, X)

We do this in IR, and there's a similar fold for the case with 2 non-constant operands just above the code diff in this patch.

This was discussed in D79718 <https://reviews.llvm.org/D79718>, and the extra shuffle in the test (llvm/test/CodeGen/X86/vector-fshl-128.ll::sink_splatvar) where it was noticed disappears because demanded elements analysis is no longer blocked. The large majority of the test diffs seem to be benign code scheduling changes, but I do see another type of win: moving the splat later allows binop narrowing in some cases. I don't see any obvious regressions; those were avoided on x86 and ARM with the INSERT_VECTOR_ELT restriction.


https://reviews.llvm.org/D79886

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/test/CodeGen/X86/vector-fshl-128.ll
  llvm/test/CodeGen/X86/vector-fshl-256.ll
  llvm/test/CodeGen/X86/vector-fshl-512.ll
  llvm/test/CodeGen/X86/vector-fshl-rot-128.ll
  llvm/test/CodeGen/X86/vector-fshr-128.ll
  llvm/test/CodeGen/X86/vector-fshr-256.ll
  llvm/test/CodeGen/X86/vector-fshr-512.ll
  llvm/test/CodeGen/X86/vector-fshr-rot-128.ll
  llvm/test/CodeGen/X86/vector-fshr-rot-256.ll
  llvm/test/CodeGen/X86/vector-rotate-128.ll
  llvm/test/CodeGen/X86/vector-shift-ashr-128.ll
  llvm/test/CodeGen/X86/vector-shift-lshr-128.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79886.263768.patch
Type: text/x-patch
Size: 265888 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200513/f1a37962/attachment-0001.bin>


More information about the llvm-commits mailing list