[llvm] [InstCombine] Add cast support in simplifyUsingControlFlow (PR #142263)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 1 00:03:19 PDT 2025


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

Miscompilation reproducer: https://alive2.llvm.org/ce/z/7aGmsm
```
define i32 @src(i32 %0) {
entry:
  %cmp120.not.i.i = icmp ne i32 %0, 0
  br i1 %cmp120.not.i.i, label %for.cond150.preheader.i.i, label %func_126.exit

for.cond150.preheader.i.i:                        ; preds = %entry
  br label %func_126.exit

func_126.exit:                                    ; preds = %for.cond150.preheader.i.i, %entry
  %storemerge14001549.lcssa.i.i = phi i32 [ -2, %entry ], [ -1, %for.cond150.preheader.i.i ]
  ret i32 %storemerge14001549.lcssa.i.i
}

define i32 @tgt(i32 %0) {
entry:
  %cmp120.not.i.i.not = icmp ne i32 %0, 0
  br i1 %cmp120.not.i.i.not, label %for.cond150.preheader.i.i, label %func_126.exit

for.cond150.preheader.i.i:                        ; preds = %entry
  br label %func_126.exit

func_126.exit:                                    ; preds = %for.cond150.preheader.i.i, %entry
  %storemerge14001549.lcssa.i.i = sext i1 %cmp120.not.i.i.not to i32
  ret i32 %storemerge14001549.lcssa.i.i
}
```

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


More information about the llvm-commits mailing list