Bug 150020 - GCC misoptimises loop with -Os
Summary: GCC misoptimises loop with -Os
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: rawhide
Hardware: powerpc
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-03-01 18:11 UTC by David Woodhouse
Modified: 2007-11-30 22:11 UTC (History)
1 user (show)

Fixed In Version: 4.0.0-0.35
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-03-21 21:00:30 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 20290 0 None None None Never

Description David Woodhouse 2005-03-01 18:11:58 UTC
Build this with -Os on ppc32. It doesn't initialise l[256].

int main(void)
{
  int i;
  unsigned l[288];

  /* set up literal table */
  for (i = 0; i < 144; i++)
    l[i] = 8;
  for (; i < 256; i++)
    l[i] = 9;
  for (; i < 280; i++)
    l[i] = 7;
  for (; i < 288; i++)
    l[i] = 8;


  printf("%d\n", l[256]);
  if (l[256] != 7)
	  printf("oops.\n");
}

Comment 1 Jakub Jelinek 2005-03-04 11:47:35 UTC
This is a bad bug, old loop.c now plays even with loops it doesn't fully
understand and doesn't take into account whether a value is increased in header,
body or latch of the loop.

Comment 2 Jakub Jelinek 2005-03-21 21:00:30 UTC
Should be fixed in gcc-4.0.0-0.35.


Note You need to log in before you can comment on or make changes to this bug.