Skip to content
Commit f9e2fb9d authored by Yingchi Long's avatar Yingchi Long
Browse files

[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
parent 942c4cda
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment