This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
-freduce-all-givs differs on P3 and P4
- From: Scott Robert Ladd <coyote at coyotegulch dot com>
- To: gcc mailing list <gcc at gcc dot gnu dot org>
- Date: Wed, 22 Oct 2003 17:13:22 -0400
- Subject: -freduce-all-givs differs on P3 and P4
I made an odd discovery (at least in my mind) whilst exploring evolution
in different environments... consider these two command lines:
A) gcc -lm -lrt -march=pentium3 \
-O3 \
-o lpbenchA lpbench.c
B) gcc -lm -lrt -march=pentium3 \
-O3 -freduce-all-givs \
-o lpbenchB lpbench.c
"B" runs 23.5% faster than "A" on a Pentium 3, due to the addition of
-freduce-all-givs. A very nice improvement.
Consider my surprise, then, when I used the following two commands on a
Pentium 4 system:
C) gcc -lm -lrt -march=pentium4 \
-O3 \
-o lpbenchC lpbench.c
D) gcc -lm -lrt -march=pentium4 \
-O3 -freduce-all-givs \
-o lpbenchD lpbench.c
Both "C" and "D" run in exactly the same time. Exchanging "pentium3" for
"pentium4" in the above command lines (i.e., running "A" and "B" on the
P4) does not change the result: for this program, -freduce-all-givs is
effective on the Pentium 3, but ineffective on the Pentium 4.
I'm not certain if this is a bug or not. If people consider it a bug,
I'll be more than happy to track down what the compiler is doing -- or I
can e-mail the lpbench.c source code to anyone interested. On the other
hand, if the observed behavior is to be expected, I'd love to know why.
I'll also note that on both test systems, -O3 is not necessary; the same
phenomena can be seen when substituting "-O1 -fstrength-reduce" for
"-O3", as in:
E) gcc -lm -lrt -march=pentium4 \
-O1 -fstrength-reduce -freduce-all-givs \
-o lpbenchD lpbench.c
"-O1 -fstrength-reduce" generates code that is just as fast as "-O3" on
this benchmark.
Command "E" may simplify understanding of the curious behavior by
reducing the number of optimizations (and thus the complexity) involved
in code generation.
Thanks.
--
Scott Robert Ladd
Coyote Gulch Productions (http://www.coyotegulch.com)
Software Invention for High-Performance Computing