diff mbox

Fix PR69352

Message ID alpine.LSU.2.11.1601191012590.31122@t29.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Jan. 19, 2016, 9:14 a.m. UTC
The following should fix PR69352 where hash collisions make
equal_mem_array_ref_p get refs it wasn't supposed to compare
and will not compare correctly (those with variable indices).

Profiledbootstrap and testing running on x86_64-unknown-linux-gnu.

Richard.

2016-01-19  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/69352
	* tree-ssa-scopedtables.c (equal_mem_array_ref_p): Constrain
	max size properly.

	* gcc.dg/torture/pr69352.c: New testcase.

Index: gcc/testsuite/gcc.dg/torture/pr69352.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr69352.c	(revision 0)
--- gcc/testsuite/gcc.dg/torture/pr69352.c	(working copy)
***************
*** 0 ****
--- 1,40 ----
+ /* { dg-do compile } */
+ 
+ int a[10][14], b, c, d, e, f, g, h, i;
+ void bar (void);
+ int
+ foo (int x)
+ {
+   unsigned j;
+   int k = 0, l;
+   int m;
+   if (h)
+     m = 12;
+   else
+     m = 13;
+   if (a[x][m])
+     l = (long) foo;
+   a[x][i] = l;
+   while (c)
+     {
+       if (b)
+ 	{
+ 	  if (f)
+ 	    k = 1;
+ 	  bar ();
+ 	}
+       for (; d;)
+ 	j++;
+     }
+   while (c)
+     {
+       if (a[x][12])
+ 	{
+ 	  if (g)
+ 	    k = 1;
+ 	  j++;
+ 	}
+       c = e;
+     }
+   return k;
+ }
diff mbox

Patch

Index: gcc/tree-ssa-scopedtables.c
===================================================================
--- gcc/tree-ssa-scopedtables.c	(revision 232519)
+++ gcc/tree-ssa-scopedtables.c	(working copy)
@@ -261,10 +261,14 @@  equal_mem_array_ref_p (tree t0, tree t1)
   bool rev0;
   HOST_WIDE_INT off0, sz0, max0;
   tree base0 = get_ref_base_and_extent (t0, &off0, &sz0, &max0, &rev0);
+  if (sz0 != max0)
+    return false;
 
   bool rev1;
   HOST_WIDE_INT off1, sz1, max1;
   tree base1 = get_ref_base_and_extent (t1, &off1, &sz1, &max1, &rev1);
+  if (sz1 != max1)
+    return false;
 
   /* Types were compatible, so these are sanity checks.  */
   gcc_assert (sz0 == sz1);