| Issue |
76318
|
| Summary |
clang is suboptimal for `(a != b) ? a + b : a + a`
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
k-arrows
|
Test case:
https://godbolt.org/z/8Tb1jrPaq
```cpp
int f(int a, int b) { return (a != b) ? a + b : a + a; }
```
This test case is based on the function `f_plus` in the following program:
https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-same-1.c
It is also interesting to note that GCC optimizations differ between `f_plus` and `g_plus`, as shown below.
https://godbolt.org/z/1hTx4jdxY
```cpp
int f_plus(int a, int b)
{
if (a != b) return a + b;
return a + a;
}
int g_plus(int a, int b)
{
if (b != a) return a + b;
return a + a;
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs