]> gcc.gnu.org Git - gcc.git/commitdiff
(fold, case PLUS_EXPR): Don't associate apart a constant operand.
authorRichard Kenner <kenner@gcc.gnu.org>
Sun, 21 Mar 1993 01:49:22 +0000 (20:49 -0500)
committerRichard Kenner <kenner@gcc.gnu.org>
Sun, 21 Mar 1993 01:49:22 +0000 (20:49 -0500)
From-SVN: r3807

gcc/fold-const.c

index ec04f44ae65a15aa27731cb0793f226f4a5e921a..97cb12374ce70b948fa37a31db1883a31c9b0a4e 100644 (file)
@@ -3424,6 +3424,12 @@ fold (expr)
                  if (code == PLUS_EXPR && operand_equal_p (var, arg1, 0))
                    return convert (TREE_TYPE (t), con);
                    
+                 /* If ARG0 is a constant, don't change things around;
+                    instead keep all the constant computations together.  */
+
+                 if (TREE_CONSTANT (arg0))
+                   return t;
+
                  /* Otherwise return (CON +- ARG1) - VAR.  */
                  TREE_SET_CODE (t, MINUS_EXPR);
                  TREE_OPERAND (t, 1) = var;
@@ -3437,6 +3443,12 @@ fold (expr)
                  if (code == MINUS_EXPR && operand_equal_p (var, arg1, 0))
                    return convert (TREE_TYPE (t), con);
                    
+                 /* If ARG0 is a constant, don't change things around;
+                    instead keep all the constant computations together.  */
+
+                 if (TREE_CONSTANT (arg0))
+                   return t;
+
                  /* Otherwise return VAR +- (ARG1 +- CON).  */
                  TREE_OPERAND (t, 1) = tem
                    = fold (build (code, TREE_TYPE (t), arg1, con));
@@ -3464,9 +3476,6 @@ fold (expr)
          if (split_tree (arg1, code, &var, &con, &varsign))
            {
              /* EXPR is ARG0 +- (CON +- VAR).  */
-             if (varsign == -1)
-               TREE_SET_CODE (t,
-                              (code == PLUS_EXPR ? MINUS_EXPR : PLUS_EXPR));
              if (TREE_CODE (t) == MINUS_EXPR
                  && operand_equal_p (var, arg0, 0))
                {
@@ -3476,6 +3485,11 @@ fold (expr)
                  return fold (build1 (NEGATE_EXPR, TREE_TYPE (t),
                                       convert (TREE_TYPE (t), con)));
                }
+             if (TREE_CONSTANT (arg1))
+               return t;
+             if (varsign == -1)
+               TREE_SET_CODE (t,
+                              (code == PLUS_EXPR ? MINUS_EXPR : PLUS_EXPR));
              TREE_OPERAND (t, 0)
                = fold (build (code, TREE_TYPE (t), arg0, con));
              TREE_OPERAND (t, 1) = var;
This page took 0.05874 seconds and 5 git commands to generate.