[PATCH] D101924: [X86] Improve costmodel for scalar byte swaps

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 5 10:24:11 PDT 2021


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

Currently we don't model i16 bswap as very high cost (`10`),
which doesn't seem right, with all other being at `1`.

Without `MOVBE`, is (an extending move plus) rot-by-8:
https://godbolt.org/z/8jrq7fMTj
I think it should at worst have throughput of `1`:

Since i32/i64 already have cost of `1`, `MOVBE` doesn't affect them.

BUT, `MOVBE` must have at least a single memory operand, with other being a register.
Which means, if we have a bswap of load, iff load has a single use, we'll fold bswap into load.
Likewise, if we have store of a bswap, iff bswap has a single use, we'll fold bswap into store.
So i think we should treat such a bswap as free.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101924

Files:
  llvm/lib/Target/X86/X86TargetTransformInfo.cpp
  llvm/test/Analysis/CostModel/X86/bswap-store.ll
  llvm/test/Analysis/CostModel/X86/bswap.ll
  llvm/test/Analysis/CostModel/X86/load-bswap.ll
  llvm/test/Transforms/SLPVectorizer/X86/arith-abs.ll
  llvm/test/Transforms/SLPVectorizer/X86/arith-add-ssat.ll
  llvm/test/Transforms/SLPVectorizer/X86/arith-add-usat.ll
  llvm/test/Transforms/SLPVectorizer/X86/arith-sub-ssat.ll
  llvm/test/Transforms/SLPVectorizer/X86/arith-sub-usat.ll
  llvm/test/Transforms/SLPVectorizer/X86/bitreverse.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101924.343101.patch
Type: text/x-patch
Size: 52669 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210505/f95c9554/attachment-0001.bin>


More information about the llvm-commits mailing list