[PATCH] D127610: [InstCombine] Optimise shift+and+xor conversion pattern to simple comparison

chenglin.bi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 12 21:50:07 PDT 2022


bcl5980 created this revision.
bcl5980 added reviewers: spatel, RKSimon, nikic, craig.topper.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
bcl5980 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

if `C1` and `C2` are pow2:

  `((C1 << X) & C2) ^ C2 --> (X != (Log2(C2)-Log2(C1)) ? C2 : 0`
  https://alive2.llvm.org/ce/z/vU9o4C


if `C1` and `C2` are pow2:

  `((C1 >> X) & C2) ^ C2 --> (X != (Log2(C1)-Log2(C2)) ? C2 : 0`
  https://alive2.llvm.org/ce/z/kr6pbR


https://reviews.llvm.org/D127610

Files:
  llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
  llvm/test/Transforms/InstCombine/and.ll
  llvm/test/Transforms/InstCombine/icmp-and-shift.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127610.436269.patch
Type: text/x-patch
Size: 4682 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220613/96652b80/attachment.bin>


More information about the llvm-commits mailing list