]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR middle-end/38751 (odd performance regression with -Os)
authorRichard Guenther <rguenther@suse.de>
Thu, 25 Jun 2009 12:39:01 +0000 (12:39 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 25 Jun 2009 12:39:01 +0000 (12:39 +0000)
2009-06-25  Richard Guenther  <rguenther@suse.de>

Backport from mainline
2009-01-07  Richard Guenther  <rguenther@suse.de>

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

gcc/ChangeLog
gcc/fold-const.c

index 33ac21488bb74da0bfe6332a189000f2228f97be..e8e5729a90a5299279f2d2215e904d9da7ca6c4c 100644 (file)
@@ -1,4 +1,14 @@
-2009-06-24  Richard Guenther  <rguenther@suse.de>
+2009-06-25  Richard Guenther  <rguenther@suse.de>
+
+       Backport from mainline
+       2009-01-07  Richard Guenther  <rguenther@suse.de>
+
+       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  <rguenther@suse.de>
 
        Backport from mainline
        2009-01-12  Jakub Jelinek  <jakub@redhat.com>
index f3c6de44ffd48c32ef63b9548e80b9bee31cb0c6..8aaae776e89c7c810b46df7e7880717849645c2a 100644 (file)
@@ -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
     {