[BENCHMARK]-mfpmath=sse should disable x387 intrinsics
Richard Guenther
richard.guenther@gmail.com
Sat Nov 27 15:30:00 GMT 2004
On Fri, 26 Nov 2004 07:38:43 -0700 (MST), Roger Sayle
<roger@eyesopen.com> wrote:
> Secondly, there are in the original tramp3d a large number of calls
> to the "pow" function. The interesting aspect here is that all but
> one of them use either 2 or 3 as the exponent. Here the middle-end
> is optimizing pow(x,2) to "x*x", and "pow(x,3)" as "x*x*x", where
> these floating point multiplications use either the SSE mult or the
> x87 mult as appropriate. In fact, GCC doesn't even have an inline
> intrinsic for pow!
Ah - yes, I remember. This is why I have
Index: libstdc++-v3/include/c_std/std_cmath.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/c_std/std_cmath.h,v
retrieving revision 1.15
diff -u -u -r1.15 std_cmath.h
--- libstdc++-v3/include/c_std/std_cmath.h 29 Dec 2003 19:26:11
-0000 1.15
+++ libstdc++-v3/include/c_std/std_cmath.h 27 Nov 2004 13:43:01 -0000
@@ -331,8 +331,33 @@
template<typename _Tp>
inline _Tp
+#if __OPTIMIZE__
+ __attribute__((always_inline))
+#endif
__pow_helper(_Tp __x, int __n)
{
+ if (__builtin_constant_p(__n))
+ switch (__n) {
+ case -1:
+ return _Tp(1)/__x;
+ case 0:
+ return _Tp(1);
+ case 1:
+ return __x;
+ case 2:
+ return __x*__x;
+#if ! __OPTIMIZE_SIZE__
+ case -2:
+ return _Tp(1)/(__x*__x);
+ case 3:
+ return __x*__x*__x;
+ case 4:
+ {
+ _Tp __y = __x*__x;
+ return __y*__y;
+ }
+#endif
+ }
return __n < 0
? _Tp(1)/__cmath_power(__x, -__n)
: __cmath_power(__x, __n);
in all of my gcc versions...
Richard.
More information about the Gcc-patches
mailing list