Question on valid transformations for cbrt

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Sat Mar 6 18:54:00 GMT 2004


I'm in the process of writing some transformations for builtin cbrt.
However it occurs to me that certain combinations might be invalid
when converting to pow, because pow doesn't like negative values with
non-integral powers.  E.g.:

	cbrt(sqrt(x)) -> pow(x, 1/6)

can be considered "safe" with -ffast-math IMO because if x was
negative the original sqrt would have choked anyway.  However here:

	cbrt(pow(x,y)) -> pow(x,y/3)

if x is negative and y is say 5, the first form would succeed but the
second would get an error EDOM because 5/3 is non-integral.  So I
don't think the latter is a valid transformation even with
-ffast-math.

(Perhaps the latter is okay if x passes tree_expr_nonnegative_p, but
that might not be worth it.)

Thoughts?

		Thanks,
		--Kaveh
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu



More information about the Gcc mailing list