[RISCV] Generaize reduction tree matching to all integer reductions (#68014) (reapply)
commit45a334d31cc3a22b1aa28ba463130eb8622abad7
authorPhilip Reames <preames@rivosinc.com>
Wed, 4 Oct 2023 17:30:47 +0000 (4 10:30 -0700)
committerPhilip Reames <listmail@philipreames.com>
Wed, 4 Oct 2023 17:41:29 +0000 (4 10:41 -0700)
treee87bfd5be577065c4e16c57e86d1f82c9f15af1a
parent7a73a2c241211ad8b492aa13bb8908589c378d16
[RISCV] Generaize reduction tree matching to all integer reductions (#68014) (reapply)

This was reverted in 824251c9b349d859a9169196cd9533c619a715ce exposed by this change in a previous patch.  Fixed in 199cbec987ee68d70611db8e7961b43c3dbad83e.  Original commit message follows.

This builds on the transform introduced in
https://github.com/llvm/llvm-project/pull/67821, and generalizes it for
all integer reduction types.

A couple of notes:
* This will only form smax/smin/umax/umin reductions when zbb is
enabled. Otherwise, we lower the min/max expressions early. I don't care
about this case, and don't plan to address this further.
* This excludes floating point. Floating point introduces concerns about
associativity. I may or may not do a follow up patch for that case.
* The explodevector test change is mildly undesirable from a clarity
perspective. If anyone sees a good way to rewrite that to stablize the
test, please suggest.
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-explodevector.ll
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-reduction-formation.ll