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] |

*From*: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>*To*: aaronl at vitelus dot com, roger at eyesopen dot com*Cc*: gcc-patches at gcc dot gnu dot org*Date*: Mon, 26 Aug 2002 12:18:56 -0400 (EDT)*Subject*: Re: [PATCH] Perform constant folding of math builtins*References*: <Pine.LNX.4.33.0208260918030.827-100000@www.eyesopen.com>

> From: Roger Sayle > > On Mon, 26 Aug 2002, Kaveh R. Ghazi wrote: > > > From: Roger Sayle <roger at eyesopen dot com> > > > The following patch implements the following optimizations: > > > > > > sqrt(0.0) = 0.0 > > > sqrt(1.0) = 1.0 > > > log(1.0) = 0.0 > > > exp(0.0) = 1.0 > > > > Why just these cases, can't you fold all calls where the argument is > > constant? (Ditto for the trig functions?) > > Hi Kaveh, > > I'd love to be able to perform constant folding for all values and > also for the trigonometric functions. There are two issues. The > first is that "cc1" is not currently linked against -lm, so the host > libm functions aren't available to the compiler. Well that's not a showstopper, you can add it if need be. > The second is that > these values need to be calculated in the precision required for the > target, so shouldn't use the host functions anyway. Why not? Aren't we talking about "unsafe" math opts? Perhaps you could lower the risk by checking that HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT, or check if we're doing a cross-compile. > Of course, I could also add "cos(0.0) = 1.0" and "sin(0.0) = 0.0" with > the existing infrastructure. Certainly, but I was hoping we could catch all math funcs with constant parameters. --Kaveh PS: Leaving constants aside, aren't there some mathematically equivalent trigonometric simplifications one could do like the log/exp ones in your original patch? -- Kaveh R. Ghazi Director of Systems Architecture ghazi@caip.rutgers.edu Qwest Solutions

**Follow-Ups**:**Re: [PATCH] Perform constant folding of math builtins***From:*Paul Koning

**Re: [PATCH] Perform constant folding of math builtins***From:*Joseph S. Myers

**References**:**Re: [PATCH] Perform constant folding of math builtins***From:*Roger Sayle

Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|

Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |