| Issue |
234680
|
| Summary |
[InstCombine] Miscompilation where merging asymmetric masked compares in a logical or
|
| Labels |
|
| Assignees |
|
| Reporter |
sairam2661
|
**Fuzzer Generated Test**
**Reproducer**
https://alive2.llvm.org/ce/z/5iXXnE
**Test Commit**
[dff64a2bf54d0abfc3c2232abb04ec28c40087ed](https://github.com/llvm/llvm-project/commit/dff64a2bf54d0abfc3c2232abb04ec28c40087ed)
**Description**
Since `x == 0` implies `trunc x to i3 != 6`, the logical or `(x == 0) || (trunc x != 6)` is just `trunc x != 6`, but InstCombine (`foldLogOpOfMaskedICmps_NotAllZeros_BMask_Mixed`, via `foldLogOpOfMaskedICmpsAsymmetric`) returns the existing `%c2` even though its constant has a poison lane, which the `select` hid whenever `%c1` is true
**Steps to reproduce**
- Minimized test case (src), `input.ll`
```llvm
define <2 x i1> @f(<2 x i8> %x) {
%c1 = icmp eq <2 x i8> %x, zeroinitializer
%t = trunc <2 x i8> %x to <2 x i3>
%c2 = icmp ne <2 x i3> %t, <i3 poison, i3 -2>
%r = select <2 x i1> %c1, <2 x i1> splat (i1 true), <2 x i1> %c2
ret <2 x i1> %r
}
```
- InstCombine output (tgt), `output.ll`
```llvm
define <2 x i1> @f(<2 x i8> %x) {
%t = trunc <2 x i8> %x to <2 x i3>
%c2 = icmp ne <2 x i3> %t, <i3 poison, i3 -2>
ret <2 x i1> %c2
}
```
**Output**
```txt
define <2 x i1> @f(<2 x i8> %x) {
#0:
%c1 = icmp eq <2 x i8> %x, { 0, 0 }
%t = trunc <2 x i8> %x to <2 x i3>
%c2 = icmp ne <2 x i3> %t, { poison, 6 }
%r = select <2 x i1> %c1, <2 x i1> { 1, 1 }, <2 x i1> %c2
ret <2 x i1> %r
}
=>
define <2 x i1> @f(<2 x i8> %x) {
#0:
%t = trunc <2 x i8> %x to <2 x i3>
%c2 = icmp ne <2 x i3> %t, { poison, 6 }
ret <2 x i1> %c2
}
Transformation doesn't verify!
ERROR: Target is more poisonous than source
Example:
<2 x i8> %x = < #x00 (0), poison >
Source:
<2 x i1> %c1 = < #x1 (1), poison >
<2 x i3> %t = < #x0 (0), poison >
<2 x i1> %c2 = < poison, poison >
<2 x i1> %r = < #x1 (1), poison >
Target:
<2 x i3> %t = < #x0 (0), poison >
<2 x i1> %c2 = < poison, poison >
Source value: < #x1 (1), poison >
Target value: < poison, poison >
Summary:
0 correct transformations
1 incorrect transformations
0 failed-to-prove transformations
0 Alive2 errors
```
**CC**: @regehr
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs