[PATCH] PPC32 performance improvements for sqrt

Steven Munroe munroesj@us.ibm.com
Thu Nov 1 22:12:00 GMT 2007


For POWER4 and later, the performance of sqrt()/sqrtf() is limited by the overhead of stacking a frame, addressing the GOT, testing for NaN etc, which is only need in  case we need to report EDOM via __kernel_standard(). For PowerPC the fsqrt[s] instruction does all the work except for setting errno to EDOM for non-zero negative values.

So the attached patch simulates prologue shrink-wrapping such that the fsqrt calculation  and basic error checking occurs before the prologure. If there are no errors the result is returned directly. Otherwise stack stack a frame and reports errors if needed via __kernel_standard(). The 32-bit version is written in asm because of bugs in gcc that insistent stacking frames even for leaf routines.

This patch only impacts builds using:

    --with-cpu=[power4,970,power5,power5+,power6,power6x]

the code for power4/970 is slightly different from that for power5 and later due to increased latency accessing the FPSCR. For micro benchmarks I see the following improvement:

    1.53 X on ppc970 2.0GHz
    1.73 X on power4 1.0GHz
    1.94 X on power5 1.9GHz
    1.66 X on power6 4.2GHz

This patch will also be release with powerpc-cpu-V0.07.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ppc32V07-sqrt-20071031.txt
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20071101/a0ddc48c/attachment.txt>


More information about the Libc-alpha mailing list