Issue 64240
Summary Missed optimization: failure to use div-by-zero UB to delete redundant select
Labels
Assignees
Reporter mcy
    Given this function:

```ll
define i64 @incorrect_safe_div(i64 %n, i64 %d) {
  %1 = icmp eq i64 %d, 0
  %2 = udiv i64 %n, %d
  %3 = select i1 %1, i64 -1, i64 %2
  ret i64 %3
}
```

LLVM does not seem to notice that this `select` is unconditional, because `%2` should imply that `%d != 0` in the entire block, and therefore `%1` can be replaced with `false`. Alive2 confirms this optimization is valid: https://alive2.llvm.org/ce/z/7nLDRe.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to