[all-commits] [llvm/llvm-project] 0c2d28: [X86] Add tests for transform `(icmp eq/ne (and X, ...
goldsteinn via All-commits
all-commits at lists.llvm.org
Tue Oct 17 23:17:16 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 0c2d28a448dee14f52c4600368da0345048588bb
https://github.com/llvm/llvm-project/commit/0c2d28a448dee14f52c4600368da0345048588bb
Author: Noah Goldstein <goldstein.w.n at gmail.com>
Date: 2023-10-18 (Wed, 18 Oct 2023)
Changed paths:
A llvm/test/CodeGen/X86/cmp-shiftX-maskX.ll
Log Message:
-----------
[X86] Add tests for transform `(icmp eq/ne (and X, C0), (shift X, C1))`; NFC
Differential Revision: https://reviews.llvm.org/D152115
Commit: 112e49b38150b8bfdef01434309d1b05204193e4
https://github.com/llvm/llvm-project/commit/112e49b38150b8bfdef01434309d1b05204193e4
Author: Noah Goldstein <goldstein.w.n at gmail.com>
Date: 2023-10-18 (Wed, 18 Oct 2023)
Changed paths:
M llvm/include/llvm/CodeGen/TargetLowering.h
M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
M llvm/lib/Target/X86/X86ISelLowering.cpp
M llvm/lib/Target/X86/X86ISelLowering.h
M llvm/test/CodeGen/X86/cmp-shiftX-maskX.ll
Log Message:
-----------
[DAGCombiner] Transform `(icmp eq/ne (and X,C0),(shift X,C1))` to use rotate or to getter constants.
If `C0` is a mask and `C1` shifts out all the masked bits (to
essentially compare two subsets of `X`), we can arbitrarily re-order
shift as `srl` or `shl`.
If `C1` (shift amount) is a power of 2, we can replace the and+shift
with a rotate.
Otherwise, based on target preference we can arbitrarily swap `shl`
and `shl` in/out to get better constants.
On x86 we can use this re-ordering to:
1) get better `and` constants for `C0` (zero extended moves or
avoid imm64).
2) covert `srl` to `shl` if `shl` will be implementable with `lea`
or `add` (both of which can be preferable).
Proofs: https://alive2.llvm.org/ce/z/qzGM_w
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D152116
Compare: https://github.com/llvm/llvm-project/compare/33430205510f...112e49b38150
More information about the All-commits
mailing list