http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49361
Summary: [4.7 Regression] Huge 470.lbm regression Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: rgue...@gcc.gnu.org CC: wschm...@gcc.gnu.org +2011-06-06 Bill Schmidt <wschm...@linux.vnet.ibm.com> + + PR tree-optimization/46728 + * builtins.c (powi_table): Remove. + (powi_lookup_cost): Remove. + (powi_cost): Remove. + (expand_powi_1): Remove. + (expand_powi): Remove. + (expand_builtin_pow_root): Remove. + (expand_builtin_pow): Remove. + (expand_builtin_powi): Eliminate handling of constant exponent. + (expand_builtin): Use expand_builtin_mathfn_2 for BUILT_IN_POW. caused a buge 470.lbm performance regression at -O3 -ffast-math. This is because when PRE inserts an expression like x * x it folds it, producing pow (x, 2.0) again which is then never expanded to x * x again. PRE does this folding in create_expression_by_pieces. Arguably not the very best idea. Eventually we should simply do 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);