[llvm] [InstCombine] Simplify phi using KnownBits of condition (PR #134712)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 9 06:10:28 PDT 2025


https://github.com/dtcxzyw requested changes to this pull request.

Miscompilation reproducer: https://alive2.llvm.org/ce/z/X5EbE5
```
; bin/opt -passes=instcombine test.ll -S
define i16 @src(i16 %ui1) {
entry:
  %cmp = icmp eq i16 %ui1, 0
  br i1 %cmp, label %cond.end, label %cond.false

cond.false:                                       ; preds = %entry
  br label %cond.end

cond.end:                                         ; preds = %cond.false, %entry
  %cond.in = phi i16 [ %ui1, %cond.false ], [ 0, %entry ]
  ret i16 %cond.in
}
```
```
define i16 @tgt(i16 %ui1) {
entry:
  %cmp = icmp eq i16 %ui1, 0
  br i1 %cmp, label %cond.end, label %cond.false

cond.false:                                       ; preds = %entry
  br label %cond.end

cond.end:
  ret i16 0
}
```

https://github.com/llvm/llvm-project/pull/134712


More information about the llvm-commits mailing list