[llvm] InstCombine: fold(select C, (X | A), X) | B into X | select C, (A | B), B. (#154246) (PR #154267)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 19 07:11:31 PDT 2025
https://github.com/dtcxzyw requested changes to this pull request.
Miscompilation reproducer: https://alive2.llvm.org/ce/z/_v5Hjz
```
define i8 @src(i8 %x, i8 noundef %y) {
%v0 = icmp samesign eq i8 %y, -1
%v1 = or i8 %x, 4
%v2 = select i1 %v0, i8 %v1, i8 %x
%v31 = and i8 -2, %v2
ret i8 %v31
}
define i8 @tgt(i8 %x, i8 noundef %y) {
%v31 = or i8 %x, -2
ret i8 %v31
}
```
Infinite loop reproducer:
```
; bin/opt -passes=instcombine reduced.ll -S
define i64 @func_48(i1 %cmp268, i64 %conv272) {
entry:
br label %for.body200
for.body200: ; preds = %for.body200, %entry
%0 = phi i64 [ 0, %entry ], [ %or273, %for.body200 ]
%and = and i64 1, %0
%or253 = or i64 %and, 4398243566277173332
%1 = select i1 %cmp268, i64 %or253, i64 %and
%or273 = or i64 %1, %conv272
br label %for.body200
}
```
https://github.com/llvm/llvm-project/pull/154267
More information about the llvm-commits
mailing list