[PATCH] D117794: [ISEL] Canonicalise constant splats to RHS.

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 20 08:47:22 PST 2022


sdesmalen created this revision.
Herald added subscribers: steven.zhang, pengfei, hiraditya, nemanjai.
sdesmalen requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

SelectionDAG::getNode() canonicalises constants to the RHS if the
operation is commutative, but it doesn't do so for constant splat
vectors. Doing this early helps making certain folds on vector types,
simplifying the code required for target DAGCombines that are enabled
before Type legalization.

Somewhat to my surprise, DAGCombine doesn't seem to traverse the
DAG in a post-order DFS, so at the time of doing some custom fold where
the input is a MUL, DAGCombiner::visitMUL hasn't yet reordered the
constant splat to the RHS.

This patch leads to a few improvements, but also a few  minor regressions,
which I traced down to D46492 <https://reviews.llvm.org/D46492>. When I tried reverting this change to see
if the changes were still necessary, I ran into some segfaults. Not sure
if there is some latent bug there.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117794

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/test/CodeGen/AArch64/unfold-masked-merge-vector-variablemask-const.ll
  llvm/test/CodeGen/PowerPC/combine-fneg.ll
  llvm/test/CodeGen/PowerPC/repeated-fp-divisors.ll
  llvm/test/CodeGen/X86/dpbusd_const.ll
  llvm/test/CodeGen/X86/extractelement-fp.ll
  llvm/test/CodeGen/X86/fp-round.ll
  llvm/test/CodeGen/X86/fp128-cast.ll
  llvm/test/CodeGen/X86/hoist-and-by-const-from-shl-in-eqcmp-zero.ll
  llvm/test/CodeGen/X86/pr43509.ll
  llvm/test/CodeGen/X86/unfold-masked-merge-vector-variablemask-const.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117794.401655.patch
Type: text/x-patch
Size: 18363 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220120/d4c3a52b/attachment-0001.bin>


More information about the llvm-commits mailing list