[llvm-bugs] [Bug 45966] New: Failure to optimize result of function in switch optimally
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon May 18 00:34:27 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45966
Bug ID: 45966
Summary: Failure to optimize result of function in switch
optimally
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: gabravier at gmail.com
CC: llvm-bugs at lists.llvm.org
inline int check(int i, int j)
{
if (i == j)
return 0;
else if (i > j)
return 1;
else
return 2;
}
int foo(int i, int j)
{
switch (check(i, j))
{
case 0:
return i + j;
case 1:
return i;
case 2:
return j;
}
}
`foo` can be optimized to `return (i == j) ? (i + j) : ((i > j) ? i : j)`. This
transformation is done by GCC, but not by LLVM.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200518/246ccbf6/attachment.html>
More information about the llvm-bugs
mailing list