[PATCH] D111919: [RISCV][WebAssembly][TargetLowering] Allow expandCTLZ/expandCTTZ to rely on CTPOP expansion for vectors.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 15 18:40:25 PDT 2021


craig.topper created this revision.
craig.topper added reviewers: spatel, frasercrmck, tlively, RKSimon.
Herald added subscribers: achieveartificialintelligence, vkmr, ecnelises, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, sunfish, simoncook, johnrusso, rbar, asb, hiraditya, jgravelle-google, sbc100, dschuff.
craig.topper requested review of this revision.
Herald added subscribers: MaskRay, aheejin.
Herald added a project: LLVM.

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. I'm not sure if this is the right thing
for WebAssembly which does have scalar ctlz and cttz instructions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111919

Files:
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.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



More information about the llvm-commits mailing list