[PATCH] D140666: [InstCombine] combine intersection for inequality icmps

Yingchi Long via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 25 22:50:26 PST 2022


inclyc created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
inclyc requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

  define i1 @masked_and_ne(i32 %A) {
    %mask1 = and i32 %A, 15
    %tst1 = icmp ne i32 %mask1, 5
    %mask2 = and i32 %A, 39
    %tst2 = icmp ne i32 %mask2, 37
    %res = and i1 %tst1, %tst2
    ret i1 %res
  }

->

  define i1 @masked_and_ne(i32 %A) {
    %1 = and i32 %A, 7
    %res = icmp ne i32 %1, 2
    ret i1 %res
  }

Assume that (B & D) & (C ^ E) == 0, transforms:

(icmp ne (A & B), C) & (icmp ne (A & D), E)
-> (icmp ne (A & (B&D)), (C&E))

Fixes: https://github.com/llvm/llvm-project/issues/59680


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140666

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140666.485267.patch
Type: text/x-patch
Size: 5450 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221226/5ce8b85e/attachment.bin>


More information about the llvm-commits mailing list