From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28670 invoked by alias); 11 Mar 2007 20:40:09 -0000 Received: (qmail 28574 invoked by uid 48); 11 Mar 2007 20:39:57 -0000 Date: Sun, 11 Mar 2007 20:40:00 -0000 Message-ID: <20070311203957.28573.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug tree-optimization/31130] [4.3 Regression] VRP no longer derives range for division after negation In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "ian at airs dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-03/txt/msg00987.txt.bz2 ------- Comment #1 from ian at airs dot com 2007-03-11 20:39 ------- I am testing this patch. Index: gcc/tree-vrp.c =================================================================== --- gcc/tree-vrp.c (revision 122820) +++ gcc/tree-vrp.c (working copy) @@ -2142,13 +2142,11 @@ extract_range_from_unary_expr (value_ran min = fold_unary_to_constant (code, TREE_TYPE (expr), vr0.max); else if (needs_overflow_infinity (TREE_TYPE (expr))) { - if (supports_overflow_infinity (TREE_TYPE (expr))) - min = positive_overflow_infinity (TREE_TYPE (expr)); - else - { - set_value_range_to_varying (vr); - return; - } + /* Negating TYPE_MIN_VALUE gives us a minimum value of + positive overflow infinity, and there is nothing useful + we can do with such a range. */ + set_value_range_to_varying (vr); + return; } else min = TYPE_MIN_VALUE (TREE_TYPE (expr)); @@ -2161,8 +2159,16 @@ extract_range_from_unary_expr (value_ran max = fold_unary_to_constant (code, TREE_TYPE (expr), vr0.min); else if (needs_overflow_infinity (TREE_TYPE (expr))) { - if (supports_overflow_infinity (TREE_TYPE (expr))) - max = positive_overflow_infinity (TREE_TYPE (expr)); + /* We have a non-overflowed TYPE_MIN as the minimum value. + If TYPE_MIN is also the maximum value, then negating this + gives us a positive overflow, and we just go straight to + varying since we will get there anyhow at the bottom of + this function. Otherwise TYPE_MIN is a half-range + [TYPE_MIN, X] without overflow, so we flip it to a + half-range [-X, TYPE_MAX] without overflow. */ + if (vr0.max != TYPE_MIN_VALUE (TREE_TYPE (expr)) + && !is_negative_overflow_infinity (vr0.max)) + max = TYPE_MAX_VALUE (TREE_TYPE (expr)); else { set_value_range_to_varying (vr); -- ian at airs dot com changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |ian at airs dot com |dot org | Status|UNCONFIRMED |ASSIGNED Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2007-03-11 20:39:57 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31130