Commit f1da2df1 by Uros Bizjak Committed by Uros Bizjak

re PR middle-end/32279 (Fold 1.0/sqrt(x/y) to sqrt(y/x))

	PR middle-end/32279
	* fold-const (fold_binary) [RDIV_EXPR]: Optimize a/sqrt(b/c)
	into a*sqrt(c/b) if flag_unsafe_math_optimizations is set.

testsuite/ChangeLog:

	PR middle-end/32279
	* gcc.dg/builtins-11.c: Also check folding of a/sqrt(b/c).

From-SVN: r125614
parent 93e17a25
2007-06-11 Uros Bizjak <ubizjak@gmail.com>
PR middle-end/32279
* fold-const (fold_binary) [RDIV_EXPR]: Optimize a/sqrt(b/c)
into a*sqrt(c/b) if flag_unsafe_math_optimizations is set.
2007-06-10 Jan Sjodin <jan.sjodin@amd.com>
Sebastian Pop <sebpop@gmail.com>
......
......@@ -10555,6 +10555,24 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
}
}
/* Optimize a/sqrt(b/c) into a*sqrt(c/b). */
if (BUILTIN_SQRT_P (fcode1))
{
tree rootarg = CALL_EXPR_ARG (arg1, 0);
if (TREE_CODE (rootarg) == RDIV_EXPR)
{
tree rootfn = TREE_OPERAND (CALL_EXPR_FN (arg1), 0);
tree b = TREE_OPERAND (rootarg, 0);
tree c = TREE_OPERAND (rootarg, 1);
tree tmp = fold_build2 (RDIV_EXPR, type, c, b);
tmp = build_call_expr (rootfn, 1, tmp);
return fold_build2 (MULT_EXPR, type, arg0, tmp);
}
}
/* Optimize x/expN(y) into x*expN(-y). */
if (BUILTIN_EXPONENT_P (fcode1))
{
......
2007-06-11 Uros Bizjak <ubizjak@gmail.com>
PR middle-end/32279
* gcc.dg/builtins-11.c: Also check folding of a/sqrt(b/c).
2007-06-10 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/32235
/* Copyright (C) 2003 Free Software Foundation.
/* Copyright (C) 2003,2007 Free Software Foundation.
Check that constant folding of built-in math functions doesn't
break anything and produces the expected results.
......@@ -36,6 +36,9 @@ void test(double x, double y, double z)
if (x/pow(y,z) != x*pow(y,-z))
link_error ();
if (x/sqrt(y/z) != x*sqrt(z/y))
link_error ();
}
int main()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment