[all-commits] [llvm/llvm-project] 679533: [SelectionDAG] Teach SelectionDAG::FoldConstantAri...

Craig Topper via All-commits all-commits at lists.llvm.org
Wed Apr 7 10:13:08 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 67953311e2e370a9fcf77595d66d39c505565382
      https://github.com/llvm/llvm-project/commit/67953311e2e370a9fcf77595d66d39c505565382
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2021-04-07 (Wed, 07 Apr 2021)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    A llvm/test/CodeGen/AArch64/pr49781.ll
    M llvm/test/CodeGen/RISCV/rvv/vadd-sdnode-rv32.ll
    M llvm/test/CodeGen/RISCV/rvv/vadd-sdnode-rv64.ll
    M llvm/test/CodeGen/RISCV/rvv/vmulh-sdnode-rv32.ll
    M llvm/test/CodeGen/RISCV/rvv/vsub-sdnode-rv32.ll
    M llvm/test/CodeGen/RISCV/rvv/vsub-sdnode-rv64.ll

  Log Message:
  -----------
  [SelectionDAG] Teach SelectionDAG::FoldConstantArithmetic to handle SPLAT_VECTOR

This allows FoldConstantArithmetic to handle SPLAT_VECTOR in
addition to BUILD_VECTOR. This allows it to support scalable
vectors. I'm also allowing fixed length SPLAT_VECTOR which is
used by some targets, but I'm not familiar enough to write tests
for those targets.

I had to block this function from running on CONCAT_VECTORS to
avoid calling getNode for a CONCAT_VECTORS of 2 scalars.
This can happen because the 2 operand getNode calls this
function for any opcode. Previously we were protected because
CONCAT_VECTORs of BUILD_VECTOR is folded to a larger BUILD_VECTOR
before that call. But it's not always possible to fold a CONCAT_VECTORS
of SPLAT_VECTORs, and we don't even try.

This fixes PR49781 where DAG combine thought constant folding
should be possible, but FoldConstantArithmetic couldn't do it.

Reviewed By: david-arm

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




More information about the All-commits mailing list