[all-commits] [llvm/llvm-project] 3a7b52: [DAGCombiner][RISCV] Handle truncating splats in i...

Luke Lau via All-commits all-commits at lists.llvm.org
Wed Apr 3 21:36:37 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3a7b5223a6639e497c856368da11b5d74ec9d6e8
      https://github.com/llvm/llvm-project/commit/3a7b5223a6639e497c856368da11b5d74ec9d6e8
  Author: Luke Lau <luke at igalia.com>
  Date:   2024-04-04 (Thu, 04 Apr 2024)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    M llvm/test/CodeGen/RISCV/intrinsic-cttz-elts-vscale.ll
    A llvm/test/CodeGen/RISCV/rvv/fold-binop-into-select.ll
    M llvm/test/CodeGen/RISCV/rvv/vscale-vw-web-simplification.ll

  Log Message:
  -----------
  [DAGCombiner][RISCV] Handle truncating splats in isNeutralConstant (#87338)

On RV64, we legalize zexts of i1s to (vselect m, (splat_vector i64 1),
(splat_vector i64 0)), where the splat_vectors are implicitly
truncating.

When the vselect is used by a binop we want to pull the vselect out via
foldSelectWithIdentityConstant. But because vectors with an element size
< i64 will truncate, isNeutralConstant will return false.

This patch handles truncating splats by getting the APInt value and
truncating it. We almost don't need to do this since most of the neutral
elements are either one/zero/all ones, but it will make a difference for
smax and smin.

I wasn't able to figure out a way to write the tests in terms of select,
since we need the i1 zext legalization to create a truncating
splat_vector.

This supercedes #87236. Fixed vectors are unfortunately not handled by
this patch (since they get legalized to _VL nodes), but they don't seem
to appear in the wild.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list