This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR83418
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 14 Dec 2017 09:54:20 +0100 (CET)
- Subject: [PATCH] Fix PR83418
- Authentication-results: sourceware.org; auth=none
IVOPTs (at least) leaves unfolded stmts in the IL and VRP overzealously
asserts they cannot happen.
Bootstrap and regtest running on x86_64-unknown-linux-gnu.
Richard.
2017-12-14 Richard Biener <rguenther@suse.de>
PR tree-optimization/83418
* vr-values.c (vr_values::extract_range_for_var_from_comparison_expr):
Instead of asserting we don't get unfolded comparisons deal with
them.
* gcc.dg/torture/pr83418.c: New testcase.
Index: gcc/vr-values.c
===================================================================
--- gcc/vr-values.c (revision 255622)
+++ gcc/vr-values.c (working copy)
@@ -445,11 +445,12 @@ vr_values::extract_range_for_var_from_co
tree min, max, type;
value_range *limit_vr;
type = TREE_TYPE (var);
- gcc_assert (limit != var);
/* For pointer arithmetic, we only keep track of pointer equality
- and inequality. */
- if (POINTER_TYPE_P (type) && cond_code != NE_EXPR && cond_code != EQ_EXPR)
+ and inequality. If we arrive here with unfolded conditions like
+ _1 > _1 do not derive anything. */
+ if ((POINTER_TYPE_P (type) && cond_code != NE_EXPR && cond_code != EQ_EXPR)
+ || limit == var)
{
set_value_range_to_varying (vr_p);
return;
Index: gcc/testsuite/gcc.dg/torture/pr83418.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr83418.c (nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr83418.c (working copy)
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+void
+yj (int j4)
+{
+ int t3;
+
+ for (t3 = 0; t3 < 6; ++t3)
+ {
+ short int v4 = t3;
+
+ if (v4 == j4 || v4 > t3)
+ for (;;)
+ {
+ }
+ }
+}