This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/20656] New: No strength reduction for a simple testcase
- 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: 27 Mar 2005 19:13:36 -0000
- Subject: [Bug tree-optimization/20656] New: No strength reduction for a simple testcase
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following two function should be equivalent:
int f(int offset, int len, int num_bytes)
{
int i;
num_bytes = 0;
for (i = 0; i < len; i++) num_bytes ++;
return num_bytes;
}
int f1(int offset, int len, int num_bytes)
{
if (len<0)
return 0;
return len;
}
Why don't we strength reduce the loop in f?
Then we just need to remove the loop and two functions would be equivalent.
The orginal code which was found in real code (I think java code in classpath):
int f(int offset, int len, int num_bytes)
{
int i;
for (i = 0; i < len; i++) num_bytes +=2;
return num_bytes;
}
int f1(int offset, int len, int num_bytes)
{
if (len<0)
return num_bytes;
return num_bytes+len*2;
}
--
Summary: No strength reduction for a simple testcase
Product: gcc
Version: 4.1.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=20656