This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/20083] New: Missed optimization with conditional and basically ||
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Feb 2005 16:50:56 -0000
- Subject: [Bug tree-optimization/20083] New: Missed optimization with conditional and basically ||
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following three functions should result in the same assembly (the last is the best, branchless and
only does one compare):
int f(int i, int j, int l)
{
int k = 0;
if (i)
k = 1;
if (j)
k = 1;
if (l)
k = 1;
return k;
}
int f1(int i, int j, int l)
{
int k = 0;
if (i)
k = 1;
else if (j)
k = 1;
else if (l)
k = 1;
return k;
}
int f2(int i, int j, int l)
{
return i||j||l;
}
Note I came up with this testcase after adding code like the above code to gcc and I was wondering how
we optimizated it.
--
Summary: Missed optimization with conditional and basically ||
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P2
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20083