[all-commits] [llvm/llvm-project] 05c64e: [DAG] Fold shuffle(bop(shuffle(x, y), shuffle(z, w)), ...

Simon Pilgrim via All-commits all-commits at lists.llvm.org
Wed Feb 17 03:43:15 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 05c64ea6722bc973ebf61653342518d065316feb
      https://github.com/llvm/llvm-project/commit/05c64ea6722bc973ebf61653342518d065316feb
  Author: Simon Pilgrim <llvm-dev at redking.me.uk>
  Date:   2021-02-17 (Wed, 17 Feb 2021)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    M llvm/lib/Target/X86/X86ISelLowering.cpp
    M llvm/test/CodeGen/X86/bitcast-and-setcc-256.ll
    M llvm/test/CodeGen/X86/promote-cmp.ll

  Log Message:
  -----------
  [DAG] Fold shuffle(bop(shuffle(x,y),shuffle(z,w)),bop(shuffle(a,b),shuffle(c,d))) (REAPPLIED)

Fold shuffle(bop(shuffle(x,y),shuffle(z,w)),bop(shuffle(a,b),shuffle(c,d))) -> bop(shuffle(x,y),shuffle(z,w)),bop(shuffle(a,b),shuffle(c,d))

Attempt to fold from a shuffle of a pair of binops to a binop of shuffles, as long as one/both of the binop sources are also shuffles that can be merged with the outer shuffle. This should guarantee that we remove one binop without introducing any additional shuffles.

Technically there's potential for a merged shuffle's lowering to be poorer than the original shuffle, but it could also be better, and I'm not seeing any regressions as long as we keep the 'don't merge splats' rule already present in MergeInnerShuffle.

This expands and generalizes an existing X86 combine and attempts to merge either of each binop's sources (with an on-the-fly commutation of the shuffle mask) - we couldn't do that in the x86 version as it had to stay in a form that DAGCombine's MergeInnerShuffle would still recognise.

Fixes issue raised by @saugustine in rG5aa8f4c0843a where we were failing to replace null shuffle operands from MergeInnerShuffle to UNDEFs.

Differential Revision: https://reviews.llvm.org/D96345




More information about the All-commits mailing list