Issue 76951
Summary [clang] Missed optimization: clang doesn't skip not used evaluation
Labels clang
Assignees
Reporter gyakh
    Hello,

I recently found that clang doesn't optimize simple code.
Specifically, it won't remove computation of `x + 777*x/34` when `bool b` is false in this code (https://godbolt.org/z/fWssbGrer):
```
int f(bool b, int x) {
 auto it = x + 777*x/34;
    if (b && it != 7) {
        return 1;
 } else {
        return 0;
    }
}
```

In other function f1, it will first check `bool b` and only compute `x + 777*x/34` when it's true.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to