[llvm-bugs] [Bug 45683] New: Bad optimization of simple switch
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Apr 26 17:07:27 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45683
Bug ID: 45683
Summary: Bad optimization of simple switch
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
int f(unsigned x)
{
switch (x)
{
case 0:
return 1;
case 1:
return 2;
}
}
This gets optimized to some rather weird code (uses `sbb` on x86) when it could
just be optimized to `return x + 1`. See here for an example of the bad
generation : https://godbolt.org/z/2fQmpH
Maybe we could change the translation of `select` (as it is used in the IR this
translates to) in order to detect cases such as this and optimize them properly
?
--
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/20200427/85b1ca2b/attachment.html>
More information about the llvm-bugs
mailing list