tree-vrp.c (vrp_int_const_binop): Do not handle MAX_EXPR when the result overflows.
authorDiego Novillo <dnovillo@redhat.com>
Wed, 15 Jun 2005 15:19:51 +0000 (15:19 +0000)
committerDiego Novillo <dnovillo@gcc.gnu.org>
Wed, 15 Jun 2005 15:19:51 +0000 (11:19 -0400)
* tree-vrp.c (vrp_int_const_binop): Do not handle MAX_EXPR
when the result overflows.

From-SVN: r100983

gcc/ChangeLog
gcc/tree-vrp.c

index 03e034fb578344327d532cb7c225f34f4e693999..b029e3ded45f3c166a793b4f86c55fb930d8a080 100644 (file)
@@ -1,3 +1,8 @@
+2005-06-15  Diego Novillo  <dnovillo@redhat.com>
+
+       * tree-vrp.c (vrp_int_const_binop): Do not handle MAX_EXPR
+       when the result overflows.
+
 2005-06-15  David Ung  <davidu@mips.com>
 
        * config/mips/mips.c (mips_rtx_cost_data): Add cost for 4kc, 4kp,
index 2569267ccf8884e23bb99b882b1c1e8367c5aade..c0d0514cf607d528fa3d6c4b2f4eacf86f299218 100644 (file)
@@ -996,9 +996,15 @@ vrp_int_const_binop (enum tree_code code, tree val1, tree val2)
       int sgn1 = tree_int_cst_sgn (val1);
       int sgn2 = tree_int_cst_sgn (val2);
 
-      /* Notice that we only need to handle the restricted set of
-        operations handled by extract_range_from_binary_expr.  */
-      if (((code == PLUS_EXPR || code == MAX_EXPR) && sgn2 >= 0)
+      /* Determine whether VAL1 CODE VAL2 yields a growing value.
+        Notice that we only need to handle the restricted set of
+        operations handled by extract_range_from_binary_expr:
+
+        VAL1 + VAL2 grows if VAL2 is >= 0.
+        VAL1 * VAL2 grows if both VAL1 and VAL2 have the same sign.
+        VAL1 - VAL2 grows if VAL2 is < 0 (because it becomes an addition).
+      */
+      if ((code == PLUS_EXPR && sgn2 >= 0)
          || (code == MULT_EXPR && sgn1 == sgn2)
          || (code == MINUS_EXPR && sgn2 < 0))
        grows = true;