why not consfold sin(const)

Robert Dewar dewar@gnat.com
Mon Sep 20 04:27:00 GMT 2004


> Yes; but someone (I forget who) early in this thread said it was 
> "impossible" since you couldn't simulate target-specific elementary 
> functions (presumably they were assuming that the target would have 
> ill-defined or buggy routines).

Ah, now I see the discussion. This thread is actually specifically
about the possibility of doing this in -ffast-math mode. My
"impossible" comment was a note about doing it without this
mode being turned on, and yes it is impossible to simulate
target routines and precompute at compile-time the exact
values you will get at run-time (because the algorithms are
not documented -- which is not quite the same as ill-defined :-)

> I'm not saying you *should* do the ctor 
> thing, it's more a proof of concept that its possible to exactly use the 
> target functions.  You'd obviously get better code if you didn't call 
> the target functions since you could then process "2*sin(CONST)" into a 
> constant.

Well the "ctor thing" is really just a special case of CSE and
constant propagation, where you promote a constant to the top
level (a quite typical optimization actually), but it is really
not what this thread was about, which was (as you see from the
above quoted subject) about constant folding such calls.


> 
> -tim



More information about the Gcc mailing list