[llvm] [InstCombine] fold icmp of select with invertible shl (PR #147182)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 9 02:27:36 PST 2025
actinks wrote:
> Miscompilation reproducer: https://alive2.llvm.org/ce/z/-TagCh
>
Is this patch causing this error? My compilation result is https://alive2.llvm.org/ce/z/enaJTE @dtcxzyw
```
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 sgt i64 %indvars.iv.i, 0
br i1 %cmp104.i.i.i, label %lor.rhs106.i.i.i, label %lor.end157.i.i.i
lor.rhs106.i.i.i: ; preds = %entry
br label %lor.end157.i.i.i
lor.end157.i.i.i: ; preds = %lor.rhs106.i.i.i, %entry
%tobool166.not.i.i.i1 = icmp eq i32 %conv161.i.i.i, 0
%tobool166.not.i.i.i = select i1 %cmp104.i.i.i, i1 %tobool166.not.i.i.i1, i1 false
ret i1 %tobool166.not.i.i.i
}
```
https://github.com/llvm/llvm-project/pull/147182
More information about the llvm-commits
mailing list