Bug 21015 - [3.4 Regression] Bad loop optimization with -O2
Summary: [3.4 Regression] Bad loop optimization with -O2
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.4.3
: P2 normal
Target Milestone: 3.4.5
Assignee: Not yet assigned to anyone
URL:
Keywords: monitored, wrong-code
Depends on: 17860
Blocks:
  Show dependency treegraph
 
Reported: 2005-04-14 00:31 UTC by Philippe Troin
Modified: 2005-05-24 08:12 UTC (History)
3 users (show)

See Also:
Host: i686-redhat-linux-gnu
Target: i686-redhat-linux-gnu
Build: i686-redhat-linux-gnu
Known to work: 2.95.3 4.0.0 4.1.0
Known to fail: 3.3.3 3.4.0 3.0
Last reconfirmed: 2005-04-14 00:34:43


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Troin 2005-04-14 00:31:25 UTC
The enclosed program prints only "0" when compiled with -O2.  It should print
"0" and "1".  I've also tried 3.2.2 and the error is present.

Phil.

#include <stdio.h>

void
f(int start)
{
  int i, end;

  for (i = end = start; i <= end; ++i)
    {
      printf("%d\n", i);
      if (i == start)
	end = 1;
    }
}

int
main()
{
  f(0);
  return 0;
}
Comment 1 Andrew Pinski 2005-04-14 00:34:43 UTC
Confirmed, only a regression on the 3.4 branch.
Comment 2 Volker Reichelt 2005-04-14 08:19:47 UTC
The compiler fails since gcc 3.0.

Looks very similar to PR 17860.
Comment 3 Paolo Bonzini 2005-04-14 08:44:17 UTC
Does the patch there fix it?
Comment 4 Volker Reichelt 2005-04-14 09:25:24 UTC
Subject: Re:  [3.3/3.4 Regression] Bad loop
 optimization with -O2

On 14 Apr, bonzini at gcc dot gnu dot org wrote:
> Does the patch there fix it?

Alas not.