This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/31130] [4.3 Regression] VRP no longer derives range for division after negation
- From: "ian at airs dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Mar 2007 20:39:57 -0000
- Subject: [Bug tree-optimization/31130] [4.3 Regression] VRP no longer derives range for division after negation
- References: <bug-31130-10053@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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