| Issue |
71383
|
| Summary |
Example of `expr1 ? expr2 : expr3` that consists only of inequality expressions and cannot be simplified by clang
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
k-arrows
|
Consider the following functions.
https://godbolt.org/z/98EoarhzM
```cpp
// expr1 ? expr2 : expr3 --> expr1
int foo1(int a)
{
return (a < 5) ? (a < 7) : (a < 3);
}
// expr1 ? expr2 : expr3 --> expr2
int foo2(int a)
{
return (a < 7) ? (a < 3) : (a < 5);
}
// expr1 ? expr2 : expr3 --> expr3
int foo3(int a)
{
return (a < 3) ? (a < 5) : (a < 7);
}
```
GCC can simplify these functions. If you rewrite these functions in if-else form as shown below, clang can simplify those.
https://godbolt.org/z/oxjWThe74
```cpp
int bar1(int a)
{
if(a < 5) return (a < 7);
else return (a < 3);
}
int bar2(int a)
{
if(a < 7) return (a < 3);
else return (a < 5);
}
int bar3(int a)
{
if(a < 3) return (a < 5);
else return (a < 7);
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs