[LLVMbugs] [Bug 6212] New: Clang misses optimisation on if vs else if
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Tue Feb 2 05:53:21 PST 2010
http://llvm.org/bugs/show_bug.cgi?id=6212
Summary: Clang misses optimisation on if vs else if
Product: libraries
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Scalar Optimizations
AssignedTo: unassignedbugs at nondot.org
ReportedBy: arplynn at gmail.com
CC: llvmbugs at cs.uiuc.edu
int test1(int mainType, int subType)
{
if(mainType == 7)
{
subType = 4;
}
else if(mainType == 9)
{
subType = 6;
}
else if(mainType == 11)
{
subType = 9;
}
return subType;
}
int test2(int mainType, int subType)
{
if(mainType == 7)
{
subType = 4;
}
if(mainType == 9)
{
subType = 6;
}
if(mainType == 11)
{
subType = 9;
}
return subType;
}
Clang generates more efficient code in the second case than the first, because
the first is transformed into a switch which then gets expanded to longer code
by the code generator.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list