| Issue |
183498
|
| Summary |
`InstCombine` folds `or (select ...)` but not `or (..., select)` after PR #166102
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
ariskeirio
|
**Description**
After PR #166102, `InstCombine` folds the pattern when the `select` is the first operand of a commutative `or`, but does not perform the same fold when the operands are swapped.
------
**src1**
```llvm
define i32 @src1(i32 %a, i32 %b) {
%cmp = icmp eq i32 %a, 0
%sel = select i1 %cmp, i32 %b, i32 0
%or = or i32 %sel, %a
ret i32 %or
}
```
InstCombine produces:
```llvm
define i32 @tgt1(i32 %a, i32 %b) {
%cmp = icmp eq i32 %a, 0
%or = select i1 %cmp, i32 %b, i32 %a
ret i32 %or
}
```
------
**src2 (commuted form)**
```llvm
define i32 @src2(i32 %a, i32 %b) {
%cmp = icmp eq i32 %a, 0
%sel = select i1 %cmp, i32 %b, i32 0
%or = or i32 %a, %sel
ret i32 %or
}
```
InstCombine keeps it unchanged:
```llvm
define i32 @tgt2(i32 %a, i32 %b) {
%cmp = icmp eq i32 %a, 0
%sel = select i1 %cmp, i32 %b, i32 0
%or = or i32 %a, %sel
ret i32 %or
}
```
Expected: `src2` should be folded the same way as `src1`.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs