[v3] conditional tweak

Martin Sebor sebor@roguewave.com
Mon Nov 10 19:04:00 GMT 2003


Martin Sebor wrote:

...
> The .s files are attached for those who don't have access to an IA64
> machine.
> 
> Martin
> 
> int foo (int n)
> 

Oops, the code I used actually looked like this:

#if !defined (__GNUC__) || !defined (HINT)
#  define __builtin_expect(e, v)   e
#endif

int foo (int n) {

#ifdef NEG

     if (__builtin_expect (n < 2, false)) {

#if defined __HP_aCC && defined HINT
#  pragma ESTIMATED_FREQUENCY 0
#endif

         return 1;
     }

     return n * foo (n - 1);

#else

     if (__builtin_expect (n > 1, true)) {

#if defined __HP_aCC && defined HINT
#  pragma ESTIMATED_FREQUENCY 0
#endif

         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
> 




More information about the Libstdc++ mailing list