[PATCH] Always expand pow(x,2.0) as x*x
Roger Sayle
roger@eyesopen.com
Sun Feb 1 03:16:00 GMT 2004
Many thanks to Richard Guenther for pointing out that we weren't
expanding pow(x,2.0) as x*x without -ffast-math. The issue/mismatch
is that although expand_builtin_pow contains code that checks for
flag_unsafe_math_optimizations and inlines exponents -1, 0, 1, and 2
even when it isn't set, that function doesn't get called if the
flag_unsafe_math_optimizations flag isn't set. Doh!
The following patch simply shuffles around the code such that we
always call expand_builtin_pow, but that function then doesn't
call expand_builtin_mathfn2 unless its considered safe to do so.
The following patch has been tested on i686-pc-linux-gnu with a
full "make bootstrap", all languages except treelang, and regression
tested with a top-level "make -k check" with no new failures.
Ok for mainline?
2004-01-31 Roger Sayle <roger@eyesopen.com>
* builtins.c (expand_builtin_pow): If flag_unsafe_math_optimizations
isn't set, don't call expand_builtin_mathfn_2 to use the pow optab.
(expand_builtin): Always call expand_builtin_pow.
Index: builtins.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/builtins.c,v
retrieving revision 1.278
diff -c -3 -p -r1.278 builtins.c
*** builtins.c 23 Jan 2004 16:16:33 -0000 1.278
--- builtins.c 1 Feb 2004 00:20:56 -0000
*************** expand_builtin_pow (tree exp, rtx target
*** 2139,2145 ****
}
}
}
! return expand_builtin_mathfn_2 (exp, target, NULL_RTX);
}
/* Expand expression EXP which is a call to the strlen builtin. Return 0
--- 2139,2148 ----
}
}
}
!
! if (! flag_unsafe_math_optimizations)
! return NULL_RTX;
! return expand_builtin_mathfn_2 (exp, target, subtarget);
}
/* Expand expression EXP which is a call to the strlen builtin. Return 0
*************** expand_builtin (tree exp, rtx target, rt
*** 5069,5076 ****
case BUILT_IN_POW:
case BUILT_IN_POWF:
case BUILT_IN_POWL:
- if (! flag_unsafe_math_optimizations)
- break;
target = expand_builtin_pow (exp, target, subtarget);
if (target)
return target;
--- 5072,5077 ----
Roger
--
Roger Sayle, E-mail: roger@eyesopen.com
OpenEye Scientific Software, WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road, Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507. Fax: (+1) 505-473-0833
More information about the Gcc-patches
mailing list