From: Richard Guenther Date: Thu, 25 Jun 2009 12:39:01 +0000 (+0000) Subject: backport: re PR middle-end/38751 (odd performance regression with -Os) X-Git-Tag: releases/gcc-4.3.4~110 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa0ee8ac21c3a58966136d2f36a93914ef1590bc;p=thirdparty%2Fgcc.git backport: re PR middle-end/38751 (odd performance regression with -Os) 2009-06-25 Richard Guenther Backport from mainline 2009-01-07 Richard Guenther PR middle-end/38751 * fold-const.c (extract_muldiv): Remove obsolete comment. (fold_plusminus_mult_expr): Undo MINUS_EXPR to PLUS_EXPR canonicalization for the canonicalization. From-SVN: r148943 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 33ac21488bb7..e8e5729a90a5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,14 @@ -2009-06-24 Richard Guenther +2009-06-25 Richard Guenther + + Backport from mainline + 2009-01-07 Richard Guenther + + PR middle-end/38751 + * fold-const.c (extract_muldiv): Remove obsolete comment. + (fold_plusminus_mult_expr): Undo MINUS_EXPR + to PLUS_EXPR canonicalization for the canonicalization. + +2009-06-25 Richard Guenther Backport from mainline 2009-01-12 Jakub Jelinek diff --git a/gcc/fold-const.c b/gcc/fold-const.c index f3c6de44ffd4..8aaae776e89c 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -5994,10 +5994,6 @@ optimize_minmax_comparison (enum tree_code code, tree type, tree op0, tree op1) expression would not overflow or that overflow is undefined for the type in the language in question. - We also canonicalize (X + 7) * 4 into X * 4 + 28 in the hope that either - the machine has a multiply-accumulate insn or that this is part of an - addressing calculation. - If we return a non-null expression, it is an equivalent form of the original computation, but need not be in the original type. @@ -7422,7 +7418,17 @@ fold_plusminus_mult_expr (enum tree_code code, tree type, tree arg0, tree arg1) else if (TREE_CODE (arg1) == INTEGER_CST) { arg10 = build_one_cst (type); - arg11 = arg1; + /* As we canonicalize A - 2 to A + -2 get rid of that sign for + the purpose of this canonicalization. */ + if (TREE_INT_CST_HIGH (arg1) == -1 + && negate_expr_p (arg1) + && code == PLUS_EXPR) + { + arg11 = negate_expr (arg1); + code = MINUS_EXPR; + } + else + arg11 = arg1; } else {