[all-commits] [llvm/llvm-project] f9e2fb: [InstCombine] combine intersection for inequality ...
Yingchi Long via All-commits
all-commits at lists.llvm.org
Thu Feb 9 20:51:08 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f9e2fb9d8e59e5a6428727d984c95753d57c3bb8
https://github.com/llvm/llvm-project/commit/f9e2fb9d8e59e5a6428727d984c95753d57c3bb8
Author: Yingchi Long <i at lyc.dev>
Date: 2023-02-10 (Fri, 10 Feb 2023)
Changed paths:
M llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
M llvm/test/Transforms/InstCombine/icmp-logical.ll
Log Message:
-----------
[InstCombine] combine intersection for inequality icmps
```
define i1 @src(i32 %A) {
%mask1 = and i32 %A, 15 ; 0x0f
%tst1 = icmp eq i32 %mask1, 3 ; 0x03
%mask2 = and i32 %A, 255 ; 0xff
%tst2 = icmp eq i32 %mask2, 243; 0xf3
%res = or i1 %tst1, %tst2
ret i1 %res
}
```
->
```
define i1 @tgt(i32 %A) {
%1 = and i32 %A, 15
%res = icmp eq i32 %1, 3
ret i1 %res
}
```
Proof: https://alive2.llvm.org/ce/z/4AyvcE
Assume that `(B & D) & (C ^ E) == 0`, and `(B & D) == D || (B & D) == B`,
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
Reviewed By: spatel, bcl5980
Differential Revision: https://reviews.llvm.org/D140666
More information about the All-commits
mailing list