This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Optimize -1.0*x into -x


On Thu, May 23, 2002 at 06:31:53PM -0600, Roger Sayle wrote:
> The following patch transforms the floating point multiplication
> -1.0 * x into the equivalent -x.  This allows use of the faster
> floating point negation instructions, e.g. fchs on x86.  I believe
> that this transformation is always valid for IEEE math, including
> NaNs, infinities and signed zeros, but I thought I'd get a second
> opinion from the reviewer/FP lawyers.

It is safe unless we're looking for acrued exception bits.  Which gcc
isn't terribly consistent at doing.  Technically this is only important
for C99 #pragma STDC FENV_ACCESS on, which we don't support yet.  But
I think leaving it -ffast-math is a good idea for now.

> 	* tree.c (real_minus_onep): New function to test for -1.0.
> 	* fold-const.c (fold) [MULT_EXPR]:  Optimize -1.0*x into -x.
> 	* gcc.dg/fnegate-1.c: New test case.

Ok.


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]