public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/20656] New: No strength reduction for a simple testcase
@ 2005-03-27 19:13 pinskia at gcc dot gnu dot org
  2005-04-06 18:50 ` [Bug tree-optimization/20656] " pinskia at gcc dot gnu dot org
  2005-07-27 13:56 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-27 19:13 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-07-27 13:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-27 19:13 [Bug tree-optimization/20656] New: No strength reduction for a simple testcase pinskia at gcc dot gnu dot org
2005-04-06 18:50 ` [Bug tree-optimization/20656] " pinskia at gcc dot gnu dot org
2005-07-27 13:56 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).