[PATCH] D152568: [InstCombine] Transform `(bitwise1 (bitwise2 (lshift1 X, C), C1), (lshift2 Y, C))`

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 9 11:02:17 PDT 2023


goldstein.w.n created this revision.
goldstein.w.n added reviewers: nikic, RKSimon.
Herald added subscribers: StephenFan, 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.

We can transform to:
`(lshift1 (bitwise1 (bitwise2 X, (inv_lshift1 C, C1), Y)), C1)`

Saving an instruction IFF:
`lshift1` is same opcode as `lshift2`
Either `bitwise1` and/or `bitwise2` is `and`.

Proof: https://alive2.llvm.org/ce/z/jejvxD

This is to help fix the regression caused in D151807 <https://reviews.llvm.org/D151807>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152568

Files:
  llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
  llvm/test/Transforms/InstCombine/bitwise-and-shifts.ll
  llvm/test/Transforms/InstCombine/or-shifted-masks.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152568.530024.patch
Type: text/x-patch
Size: 9739 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230609/1cd00cf1/attachment.bin>


More information about the llvm-commits mailing list