This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/20656] New: No strength reduction for a simple testcase


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]