[PATCH] Clear SSA_NAME_ANTI_RANGE_P when appropriate (PR tree-optimization/67821)

Marek Polacek polacek@redhat.com
Mon Oct 5 13:53:00 GMT 2015


Here, we were crashing on an assert in duplicate_ssa_name_range_info:

506   gcc_assert (!SSA_NAME_ANTI_RANGE_P (name));

The problem is that reset_flow_sensitive_info wasn't clearing the
SSA_NAME_ANTI_RANGE_P flag; I don't think NULL SSA_NAME_RANGE_INFO
can ever describe an anti-range...

Bootstrapped/regtested on x86_64-linux, ok for trunk/5?

2015-10-05  Marek Polacek  <polacek@redhat.com>

	PR tree-optimization/67821
	* tree-ssanames.c (reset_flow_sensitive_info): Also clear
	the SSA_NAME_ANTI_RANGE_P flag.

	* gcc.dg/torture/pr67821-2.c: New test.
	* gcc.dg/torture/pr67821.c: New test.

diff --git gcc/testsuite/gcc.dg/torture/pr67821-2.c gcc/testsuite/gcc.dg/torture/pr67821-2.c
index e69de29..38cfc84 100644
--- gcc/testsuite/gcc.dg/torture/pr67821-2.c
+++ gcc/testsuite/gcc.dg/torture/pr67821-2.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+int a, b, c, d, e, g;
+short f;
+
+void
+fn1 ()
+{
+  int i;
+  f = a - b;
+  e = (c && (i = d = (unsigned) f - 1)) || i;
+  g = (unsigned) f - 1;
+  c && (d = 0);
+}
diff --git gcc/testsuite/gcc.dg/torture/pr67821.c gcc/testsuite/gcc.dg/torture/pr67821.c
index e69de29..1c9e8b9 100644
--- gcc/testsuite/gcc.dg/torture/pr67821.c
+++ gcc/testsuite/gcc.dg/torture/pr67821.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+int isdigit (int);
+
+int
+foo (const char *s)
+{
+  int success = 1;
+  const char *p = s + 2;
+  if (!isdigit (*p))
+    success = 0;
+  while (isdigit (*p))
+    ++p;
+  return success;
+}
diff --git gcc/tree-ssanames.c gcc/tree-ssanames.c
index 64e2379..c3484fe 100644
--- gcc/tree-ssanames.c
+++ gcc/tree-ssanames.c
@@ -561,7 +561,10 @@ reset_flow_sensitive_info (tree name)
 	mark_ptr_info_alignment_unknown (SSA_NAME_PTR_INFO (name));
     }
   else
-    SSA_NAME_RANGE_INFO (name) = NULL;
+    {
+      SSA_NAME_RANGE_INFO (name) = NULL;
+      SSA_NAME_ANTI_RANGE_P (name) = 0;
+    }
 }
 
 /* Clear all flow sensitive data from all statements and PHI definitions

	Marek



More information about the Gcc-patches mailing list