[PATCH] D65319: [ScalarizeMaskedMemIntrin] Bitcast the mask to the scalar domain and use scalar bit tests for the branches.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 25 23:52:58 PDT 2019


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

X86 at least is able to use movmsk or kmov to move the mask to the scalar
domain. Then we can just use test instructions to test individual bits.

This is more efficient than extracting each mask element
individually.

I special cased v1i1 to use the previous behavior. This avoids
poor type legalization of bitcast of v1i1 to i1.

I've skipped expandload/compressstore as I think we need to
handle constant masks for those better first.

Many tests end up with duplicate test instructions due to tail
duplication in the branch folding pass. But the same thing
happens when constructing similar code in C. So its not unique
to the scalarization.

Not sure if this lowering code will also be good for other targets,
but we're only testing X86 today.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65319

Files:
  llvm/lib/CodeGen/ScalarizeMaskedMemIntrin.cpp
  llvm/test/CodeGen/X86/avx2-masked-gather.ll
  llvm/test/CodeGen/X86/avx512-masked_memop-16-8.ll
  llvm/test/CodeGen/X86/masked_gather.ll
  llvm/test/CodeGen/X86/masked_gather_scatter.ll
  llvm/test/CodeGen/X86/masked_gather_scatter_widen.ll
  llvm/test/CodeGen/X86/masked_load.ll
  llvm/test/CodeGen/X86/masked_store.ll
  llvm/test/CodeGen/X86/masked_store_trunc.ll
  llvm/test/CodeGen/X86/masked_store_trunc_ssat.ll
  llvm/test/CodeGen/X86/masked_store_trunc_usat.ll
  llvm/test/Transforms/ScalarizeMaskedMemIntrin/X86/expand-masked-gather.ll
  llvm/test/Transforms/ScalarizeMaskedMemIntrin/X86/expand-masked-load.ll
  llvm/test/Transforms/ScalarizeMaskedMemIntrin/X86/expand-masked-store.ll





More information about the llvm-commits mailing list