Patchwork Fix PR49361

mail settings
Submitter Richard Guenther
Date June 10, 2011, 12:17 p.m.
Message ID <alpine.LNX.2.00.1106101416430.810@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/99887/
State New
Headers show


Richard Guenther - June 10, 2011, 12:17 p.m.
This fixes a fallout of pow(x,2.0) expander removal.  As discussed
several times we shouldn't really fold x*x to pow(x,2) - at least
not when we're in gimple form already as we'll never see
followup folding opportunities that folding was designed to catch.

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


2011-06-10  Richard Guenther  <>

	PR tree-optimization/49361
	* fold-const.c (fold_binary_loc): Only fold x * x to pow (x, 2.0)
	when not already in gimple form.


Index: gcc/fold-const.c
--- gcc/fold-const.c	(revision 174891)
+++ gcc/fold-const.c	(working copy)
@@ -10519,7 +10519,8 @@  fold_binary_loc (location_t loc,
 	      /* Optimize x*x as pow(x,2.0), which is expanded as x*x.  */
-	      if (optimize_function_for_speed_p (cfun)
+	      if (!in_gimple_form
+		  && optimize_function_for_speed_p (cfun)
 		  && operand_equal_p (arg0, arg1, 0))
 		  tree powfn = mathfn_built_in (type, BUILT_IN_POW);