Bug 150020

Summary: GCC misoptimises loop with -Os
Product: [Fedora] Fedora Reporter: David Woodhouse <dwmw2>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: barryn
Target Milestone: ---   
Target Release: ---   
Hardware: powerpc   
OS: Linux   
Whiteboard:
Fixed In Version: 4.0.0-0.35 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-03-21 21:00:30 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.