aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2014-04-28 14:07:51 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2014-04-28 14:07:51 +0000
commit771c950116f7b08a45eecb6334954cfe8891a587 (patch)
treef0c265427988aef0111991241732b3a1d9dea238 /gcc
parent279a935ff4bc1df86e090f8e28f15d70384514eb (diff)
downloadgcc-771c950116f7b08a45eecb6334954cfe8891a587.zip
gcc-771c950116f7b08a45eecb6334954cfe8891a587.tar.gz
gcc-771c950116f7b08a45eecb6334954cfe8891a587.tar.bz2
tree-vrp.c (vrp_var_may_overflow): Remove.
2014-04-28 Richard Biener <rguenther@suse.de> * tree-vrp.c (vrp_var_may_overflow): Remove. (vrp_visit_phi_node): Rather than bumping to +-INF possibly with overflow immediately bump to one before that value and let iteration figure out overflow status. * gcc.dg/tree-ssa/vrp91.c: New testcase. * gcc.dg/Wstrict-overflow-14.c: XFAIL. * gcc.dg/Wstrict-overflow-15.c: Likewise. * gcc.dg/Wstrict-overflow-18.c: Remove XFAIL. From-SVN: r209862
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.dg/Wstrict-overflow-14.c2
-rw-r--r--gcc/testsuite/gcc.dg/Wstrict-overflow-15.c2
-rw-r--r--gcc/testsuite/gcc.dg/Wstrict-overflow-18.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/vrp91.c22
-rw-r--r--gcc/tree-vrp.c98
7 files changed, 65 insertions, 75 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3b3f613..67a4645 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@
2014-04-28 Richard Biener <rguenther@suse.de>
+ * tree-vrp.c (vrp_var_may_overflow): Remove.
+ (vrp_visit_phi_node): Rather than bumping to +-INF possibly
+ with overflow immediately bump to one before that value and
+ let iteration figure out overflow status.
+
+2014-04-28 Richard Biener <rguenther@suse.de>
+
* configure.ac: Do valgrind header checks unconditionally.
Add --enable-valgrind-annotations.
* system.h: Guard valgrind header inclusion with
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index df5af3a..261bb98 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,12 @@
2014-04-28 Richard Biener <rguenther@suse.de>
+ * gcc.dg/tree-ssa/vrp91.c: New testcase.
+ * gcc.dg/Wstrict-overflow-14.c: XFAIL.
+ * gcc.dg/Wstrict-overflow-15.c: Likewise.
+ * gcc.dg/Wstrict-overflow-18.c: Remove XFAIL.
+
+2014-04-28 Richard Biener <rguenther@suse.de>
+
PR tree-optimization/60979
* gcc.dg/graphite/pr60979.c: New testcase.
diff --git a/gcc/testsuite/gcc.dg/Wstrict-overflow-14.c b/gcc/testsuite/gcc.dg/Wstrict-overflow-14.c
index 6f3c5a2..dda07ea 100644
--- a/gcc/testsuite/gcc.dg/Wstrict-overflow-14.c
+++ b/gcc/testsuite/gcc.dg/Wstrict-overflow-14.c
@@ -10,6 +10,6 @@ foo (int j)
int sum = 0;
for (i = 1; i < j; i += i)
- sum += i / 16; /* { dg-warning "assuming signed overflow does not occur" "" } */
+ sum += i / 16; /* { dg-warning "assuming signed overflow does not occur" "" { xfail *-*-* } } */
return sum;
}
diff --git a/gcc/testsuite/gcc.dg/Wstrict-overflow-15.c b/gcc/testsuite/gcc.dg/Wstrict-overflow-15.c
index d1627d2..c9e275c 100644
--- a/gcc/testsuite/gcc.dg/Wstrict-overflow-15.c
+++ b/gcc/testsuite/gcc.dg/Wstrict-overflow-15.c
@@ -10,6 +10,6 @@ foo (int j)
int sum = 0;
for (i = 1; i < j; i += i)
- sum += __builtin_abs (i); /* { dg-warning "assuming signed overflow does not occur" "" } */
+ sum += __builtin_abs (i); /* { dg-warning "assuming signed overflow does not occur" "" { xfail *-*-* } } */
return sum;
}
diff --git a/gcc/testsuite/gcc.dg/Wstrict-overflow-18.c b/gcc/testsuite/gcc.dg/Wstrict-overflow-18.c
index 2767c44..7bf111a 100644
--- a/gcc/testsuite/gcc.dg/Wstrict-overflow-18.c
+++ b/gcc/testsuite/gcc.dg/Wstrict-overflow-18.c
@@ -17,7 +17,7 @@ foo (struct c *p)
for (i = 0; i < p->a - p->b; ++i)
{
- if (i > 0) /* { dg-bogus "warning" "" { xfail *-*-* } } */
+ if (i > 0) /* { dg-bogus "warning" "" } */
sum += 2;
bar (p);
}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp91.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp91.c
new file mode 100644
index 0000000..68d8fd3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp91.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-S -O2 -fdump-tree-vrp2" } */
+
+unsigned short data;
+void foo ()
+{
+ unsigned char x16;
+ unsigned int i;
+ for (i = 0; i < 8; i++)
+ {
+ x16 = data & 1;
+ data >>= 1;
+ if (x16 == 1)
+ {
+ data ^= 0x4;
+ }
+ data >>= 1;
+ }
+}
+
+/* { dg-final { scan-tree-dump "\\\[0, 7\\\]" "vrp2" } } */
+/* { dg-final { cleanup-tree-dump "vrp2" } } */
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 34255ced..042f712 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -4026,52 +4026,6 @@ adjust_range_with_scev (value_range_t *vr, struct loop *loop,
}
}
-/* Return true if VAR may overflow at STMT. This checks any available
- loop information to see if we can determine that VAR does not
- overflow. */
-
-static bool
-vrp_var_may_overflow (tree var, gimple stmt)
-{
- struct loop *l;
- tree chrec, init, step;
-
- if (current_loops == NULL)
- return true;
-
- l = loop_containing_stmt (stmt);
- if (l == NULL
- || !loop_outer (l))
- return true;
-
- chrec = instantiate_parameters (l, analyze_scalar_evolution (l, var));
- if (TREE_CODE (chrec) != POLYNOMIAL_CHREC)
- return true;
-
- init = initial_condition_in_loop_num (chrec, l->num);
- step = evolution_part_in_loop_num (chrec, l->num);
-
- if (step == NULL_TREE
- || !is_gimple_min_invariant (step)
- || !valid_value_p (init))
- return true;
-
- /* If we get here, we know something useful about VAR based on the
- loop information. If it wraps, it may overflow. */
-
- if (scev_probably_wraps_p (init, step, stmt, get_chrec_loop (chrec),
- true))
- return true;
-
- if (dump_file && (dump_flags & TDF_DETAILS) != 0)
- {
- print_generic_expr (dump_file, var, 0);
- fprintf (dump_file, ": loop information indicates does not overflow\n");
- }
-
- return false;
-}
-
/* Given two numeric value ranges VR0, VR1 and a comparison code COMP:
@@ -8452,32 +8406,32 @@ vrp_visit_phi_node (gimple phi)
&& (cmp_min != 0 || cmp_max != 0))
goto varying;
- /* If the new minimum is smaller or larger than the previous
- one, go all the way to -INF. In the first case, to avoid
- iterating millions of times to reach -INF, and in the
- other case to avoid infinite bouncing between different
- minimums. */
- if (cmp_min > 0 || cmp_min < 0)
- {
- if (!needs_overflow_infinity (TREE_TYPE (vr_result.min))
- || !vrp_var_may_overflow (lhs, phi))
- vr_result.min = TYPE_MIN_VALUE (TREE_TYPE (vr_result.min));
- else if (supports_overflow_infinity (TREE_TYPE (vr_result.min)))
- vr_result.min =
- negative_overflow_infinity (TREE_TYPE (vr_result.min));
- }
-
- /* Similarly, if the new maximum is smaller or larger than
- the previous one, go all the way to +INF. */
- if (cmp_max < 0 || cmp_max > 0)
- {
- if (!needs_overflow_infinity (TREE_TYPE (vr_result.max))
- || !vrp_var_may_overflow (lhs, phi))
- vr_result.max = TYPE_MAX_VALUE (TREE_TYPE (vr_result.max));
- else if (supports_overflow_infinity (TREE_TYPE (vr_result.max)))
- vr_result.max =
- positive_overflow_infinity (TREE_TYPE (vr_result.max));
- }
+ /* If the new minimum is larger than than the previous one
+ retain the old value. If the new minimum value is smaller
+ than the previous one and not -INF go all the way to -INF + 1.
+ In the first case, to avoid infinite bouncing between different
+ minimums, and in the other case to avoid iterating millions of
+ times to reach -INF. Going to -INF + 1 also lets the following
+ iteration compute whether there will be any overflow, at the
+ expense of one additional iteration. */
+ if (cmp_min < 0)
+ vr_result.min = lhs_vr->min;
+ else if (cmp_min > 0
+ && !vrp_val_is_min (vr_result.min))
+ vr_result.min
+ = int_const_binop (PLUS_EXPR,
+ vrp_val_min (TREE_TYPE (vr_result.min)),
+ build_int_cst (TREE_TYPE (vr_result.min), 1));
+
+ /* Similarly for the maximum value. */
+ if (cmp_max > 0)
+ vr_result.max = lhs_vr->max;
+ else if (cmp_max < 0
+ && !vrp_val_is_max (vr_result.max))
+ vr_result.max
+ = int_const_binop (MINUS_EXPR,
+ vrp_val_max (TREE_TYPE (vr_result.min)),
+ build_int_cst (TREE_TYPE (vr_result.min), 1));
/* If we dropped either bound to +-INF then if this is a loop
PHI node SCEV may known more about its value-range. */