[RISCV][WebAssembly][TargetLowering] Allow expandCTLZ/expandCTTZ to rely on CTPOP...
authorCraig Topper <craig.topper@sifive.com>
Tue, 19 Oct 2021 23:10:02 +0000 (16:10 -0700)
committerCraig Topper <craig.topper@sifive.com>
Wed, 20 Oct 2021 14:46:41 +0000 (07:46 -0700)
commitfe1f0de00335a8e59aa6c08d1cdae7cf20e14f87
treebee194c97b8a768f60f3a0e0c857d731307cbac7
parent60e19f6752b7f19b022d8bdca0937c59b49811f9
[RISCV][WebAssembly][TargetLowering] Allow expandCTLZ/expandCTTZ to rely on CTPOP expansion for vectors.

Our fallback expansion for CTLZ/CTTZ relies on CTPOP. If CTPOP
isn't legal or custom for a vector type we would scalarize the
CTLZ/CTTZ. This is different than CTPOP itself which would use a
vector expansion.

This patch teaches expandCTLZ/CTTZ to rely on the vector CTPOP
expansion instead of scalarizing. To do this I had to add additional
checks to make sure the operations used by CTPOP expansions are all
supported. Some of the operations were already needed for the CTLZ/CTTZ
expansion.

This is a huge improvement to the RISCV which doesn't have a scalar
ctlz or cttz in the base ISA.

For WebAssembly, I've added Custom lowering to keep the scalarizing
behavior. I've also extended the scalarizing to CTPOP.

Differential Revision: https://reviews.llvm.org/D111919
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-ctlz.ll
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-cttz.ll
llvm/test/CodeGen/WebAssembly/simd-unsupported.ll