This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix -fprefetch-loop-arrays ICE (PR tree-optimization/36504)


Hi!

In PR33856 tree-data-ref.c has been changed, so that create_data_ref
is never called on references without base address
(e.g. VIEW_CONVERT_EXPR <some_type, 0>), but apparently
tree-ssa-loop-prefetch.c calls create_data_ref too and doesn't have this
guard.

Fixed thusly, ok for 4.3/4.4?

2008-06-24  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/36504
	* tree-ssa-loop-prefetch.c (gather_memory_references_ref): Skip
	references without base address.

	* gcc.dg/pr36504.c: New test.

--- gcc/tree-ssa-loop-prefetch.c.jj	2008-06-23 08:40:36.000000000 +0200
+++ gcc/tree-ssa-loop-prefetch.c	2008-06-24 10:40:09.000000000 +0200
@@ -457,6 +457,9 @@ gather_memory_references_ref (struct loo
   HOST_WIDE_INT step, delta;
   struct mem_ref_group *agrp;
 
+  if (get_base_address (ref) == NULL)
+    return false;
+
   if (!analyze_ref (loop, &ref, &base, &step, &delta, stmt))
     return false;
 
--- gcc/testsuite/gcc.dg/pr36504.c.jj	2008-06-24 10:43:51.000000000 +0200
+++ gcc/testsuite/gcc.dg/pr36504.c	2008-06-24 10:42:00.000000000 +0200
@@ -0,0 +1,25 @@
+/* PR tree-optimization/36504 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -fprefetch-loop-arrays" } */
+
+struct A { struct { int a; } b[8]; };
+struct B { int c; int d; };
+struct C { struct B d; };
+
+void bar (struct C *, int);
+
+struct B
+foo (struct C *p, struct A *e, int b)
+{
+  struct B q;
+  bar (p, e->b[b].a);
+  return q;
+}
+
+void
+baz (int b, struct A *e)
+{
+  struct C p;
+  for (; b; ++b)
+    p.d = foo (&p, e, b);
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]