[PATCH] D152116: [X86] Transform `(icmp eq/ne (and X, C0), (shift X, C1))` to get better constants.

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 4 12:46:44 PDT 2023


goldstein.w.n created this revision.
goldstein.w.n added reviewers: pengfei, RKSimon.
Herald added a subscriber: hiraditya.
Herald added a project: All.
goldstein.w.n requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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`.

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).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152116

Files:
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/X86/cmp-shiftX-maskX.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152116.528252.patch
Type: text/x-patch
Size: 12130 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230604/59ff9cec/attachment.bin>


More information about the llvm-commits mailing list