diff mbox

Fix PR70777

Message ID alpine.LSU.2.11.1604280937390.13384@t29.fhfr.qr
State New
Headers show

Commit Message

Richard Biener April 28, 2016, 7:46 a.m. UTC
The following removes a premature optimization/canonicalization from
fold-const.c which is now done by reassoc.  This avoids doing this
when sincos is not run (at -Og).  The reassoc pass now does this
transform (and in a more generic way by using powi).

I suspect there are a few missed simplifications regarding to
mixing powi and pow, so for the branches guarding the folding
with !optimize_debug is more appropriate.

Still on trunk we're now getting additional mult/add reassoc
features and should revisit pow[i] handling there.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.


2016-04-28  Richard Biener  <rguenther@suse.de>

	PR middle-end/70777
	* fold-const.c (fold_binary_loc): Remove x*x to pow(x,2.0)
	canonicalization.
diff mbox

Patch

Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c	(revision 235510)
+++ gcc/fold-const.c	(working copy)
@@ -10033,24 +10033,6 @@  fold_binary_loc (location_t loc,
 	      && TREE_CODE (arg1) == CONJ_EXPR
 	      && operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0))
 	    return fold_mult_zconjz (loc, type, arg0);
-
-	  if (flag_unsafe_math_optimizations)
-	    {
-
-	      /* Canonicalize x*x as pow(x,2.0), which is expanded as x*x.  */
-	      if (!in_gimple_form
-		  && optimize
-		  && operand_equal_p (arg0, arg1, 0))
-		{
-		  tree powfn = mathfn_built_in (type, BUILT_IN_POW);
-
-		  if (powfn)
-		    {
-		      tree arg = build_real (type, dconst2);
-		      return build_call_expr_loc (loc, powfn, 2, arg0, arg);
-		    }
-		}
-	    }
 	}
       goto associate;