Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Jun 2007 17:09:13 +0400
From:      Andrey Chernov <ache@nagual.pp.ru>
To:        current@freebsd.org, kan@freebsd.org
Subject:   Silent gcc 4.2.0 loop optimization bug with -O2
Message-ID:  <20070625130913.GA50273@nagual.pp.ru>

next in thread | raw e-mail | index | archive | help
This is serious loop optimization bug with -O2.
I can't cut it down to the small sample, so here are simple steps to 
reproduce:

1) Compile/install misc/astrolog port, with or WITHOUT_X11, it does not 
matter.
(I just commit CFLAGS+=-O in its Makefile as workaround of this bug, so 
change it to CFLAGS+=-O2 to see the bug in action)

2) Run "astrolog -n -j0"
See lower right corner empty (under "Mode Power Percent")

3) Change back to CFLAGS+=-O, recompile, reinstall, run, see _filled_
lower right corner.

To the code - in the intrpret.c:ChartInfluence(), near the very end of 
the file is a basic loop like that:

for (i = 1; i <= 12; i++) {
  ...
  if (i <= 4) {
    ...
  } else if (i == 6) {
    ...
  } else if (i >= 7 && i <= 9) {
!!!!! It never goes here with -O2 !!!!!
    ...
  }
  ...
}

Note: the exact example code above DOES NOT trigger the bug, as I say I 
can't cut it down to small sample, I just provide it for hint where bug 
place is.

-- 
http://ache.pp.ru/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070625130913.GA50273>