[v3] conditional tweak
Martin Sebor
sebor@roguewave.com
Mon Nov 10 18:53:00 GMT 2003
Jerry Quinn wrote:
> Gabriel Dos Reis writes:
> > Phil Edwards <phil@codesourcery.com> writes:
> >
> > | Here's my opinion before I vanish into non-networked-land for a few days:
> > | for years, the GCC team has been warning of the dangers of slowing down the
> > | compiler and runtime by a few percent at a time, because it accumulates
> > | so quickly.
> >
> > I'm just asking for an actual data. Can we have one?
> >
> > -- Gaby
>
> I didn't actually see any difference on an AMD XP2100, but the only
> other platform I can really test is a mobile P4.
I wouldn't expect to see much difference on platforms like IA32 that,
AFAIK, do not support branch prediction hints. I would expect to see
differences on platforms like PA or IA64 that can take advantage of
them. (Of course, the reality depends on the implementation of the
feature. Even on platforms that do not support branch prediction
hints the optimizer can take advantage of the hint and rearrange
code for better performance.)
Surprisingly, with gcc I didn't see any significant difference not
only on IA32 but also on IA64. When I repeated the same exercise with
HP aCC on IA64 (using #pragma ESTIMATED_FREQUENCY) the output was
considerably different and, as expected, the code performed slightly
better than without the hint.
The .s files are attached for those who don't have access to an IA64
machine.
Martin
int foo (int n) {
#ifdef NEG
if (__builtin_expect (n < 2, false))
return 1;
return n * foo (n - 1);
#else
if (__builtin_expect (n > 1, true))
return n * foo (n - 1);
return 1;
#endif
}
P.S. The commands used to generate the attached .s files are here:
$ aCC -S +O3 t.cpp -DHINT -DNEG && mv t.s acc.hint.neg.s \
&& aCC -S +O3 t.cpp -DHINT && mv t.s acc.hint.s \
&& aCC -S +O3 t.cpp -DNEG && mv t.s acc.neg.s \
&& aCC -S +O3 t.cpp && mv t.s acc.s
$ gcc -S -O3 t.cpp -DHINT -DNEG -o gcc.hint.neg.s \
&& gcc -S -O3 t.cpp -DHINT -o gcc.hint.s \
&& gcc -S -O3 t.cpp -DNEG -o gcc.neg.s \
&& gcc -S -O3 t.cpp -o gcc.s
-------------- next part --------------
A non-text attachment was scrubbed...
Name: asm.tar.gz
Type: application/x-gzip
Size: 4119 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20031110/559d6695/attachment.bin>
More information about the Libstdc++
mailing list