[PATCH] D112254: [LegalizeVectorOps][X86] Don't defer BITREVERSE expansion to LegalizeDAG.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 21 11:30:31 PDT 2021


craig.topper created this revision.
craig.topper added reviewers: RKSimon, spatel, pengfei.
Herald added a subscriber: hiraditya.
craig.topper requested review of this revision.
Herald added a project: LLVM.

By expanding early it allows the shifts to be custom lowered in
LegalizeVectorOps. Then a DAG combine is able to run on them before
LegalizeDAG handles the BUILD_VECTORS for the masks used.

v16Xi8 shift lowering on X86 requires a mask to be applied to a v8i16
shift. The BITREVERSE expansion applied an AND mask before SHL ops and
after SRL ops. This was done to share the same mask constant for both shifts.
It looks like this patch allows DAG combine to remove the AND mask added
after v16i8 SHL by X86 lowering. This maintains the mask sharing that
BITREVERSE was trying to achieve. Prior to this patch it looks like
we kept the mask after the SHL instead which required an extra constant
pool or a PANDN to invert it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112254

Files:
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
  llvm/test/CodeGen/X86/bitreverse.ll
  llvm/test/CodeGen/X86/combine-bitreverse.ll
  llvm/test/CodeGen/X86/vector-bitreverse.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112254.381337.patch
Type: text/x-patch
Size: 45892 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211021/4d4da960/attachment.bin>


More information about the llvm-commits mailing list