[llvm] [InstCombine] fold icmp of select with invertible shl (PR #147182)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 8 04:21:21 PST 2025
https://github.com/dtcxzyw requested changes to this pull request.
Miscompilation reproducer: https://alive2.llvm.org/ce/z/-TagCh
```
define i1 @src(i64 %indvars.iv.i, i32 %conv161.i.i.i) {
entry:
%cmp104.i.i.i = icmp slt i64 %indvars.iv.i, 1
br i1 %cmp104.i.i.i, label %lor.end157.i.i.i, label %lor.rhs106.i.i.i
lor.rhs106.i.i.i:
br label %lor.end157.i.i.i
lor.end157.i.i.i:
%conv159.i.i.i = zext i1 %cmp104.i.i.i to i16
%sub.i122.i.i.i = sub i16 0, %conv159.i.i.i
%conv161.i.i.i2 = zext i16 %sub.i122.i.i.i to i32
%shl.i.i.i.i = shl nuw i32 %conv161.i.i.i, 31
%cond.i124.i.i.i = select i1 %cmp104.i.i.i, i32 %conv161.i.i.i2, i32 %shl.i.i.i.i
%conv163.i.i.i = zext i32 %cond.i124.i.i.i to i64
%tobool166.not.i.i.i = icmp eq i64 %conv163.i.i.i, 0
ret i1 %tobool166.not.i.i.i
}
define i1 @tgt(i64 %indvars.iv.i, i32 %conv161.i.i.i) {
entry:
%cmp104.i.i.i = icmp slt i64 %indvars.iv.i, 1
br i1 %cmp104.i.i.i, label %lor.end157.i.i.i, label %lor.rhs106.i.i.i
lor.rhs106.i.i.i: ; preds = %entry
%0 = icmp eq i32 %conv161.i.i.i, 0
br label %lor.end157.i.i.i
lor.end157.i.i.i: ; preds = %lor.rhs106.i.i.i, %entry
%tobool166.not.i.i.i = phi i1 [ %0, %lor.rhs106.i.i.i ], [ true, %entry ]
ret i1 %tobool166.not.i.i.i
}
```
https://github.com/llvm/llvm-project/pull/147182
More information about the llvm-commits
mailing list