From 6dce7ee94db2a11359a6a9e149ff5fb80a851a0d Mon Sep 17 00:00:00 2001
From: sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 18 Sep 2006 01:54:33 +0000
Subject: [PATCH] 2006-09-17  Zdenek Dvorak <dvorakz@suse.cz>

	PR tree-optimization/28887
	* tree-ssa-loop-prefetch.c (analyze_ref): Strip nonaddressable
	component parts from the reference.
	(gather_memory_references_ref): Record the reference without the
	nonaddressable component parts.

	* gcc.dg/prefetch-loop-arrays-1.c: New test case.



git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117012 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog                                 |  8 +++++
 gcc/testsuite/ChangeLog                       |  5 +++
 gcc/testsuite/gcc.dg/prefetch-loop-arrays-1.c | 36 +++++++++++++++++++
 gcc/tree-ssa-loop-prefetch.c                  | 12 ++++---
 4 files changed, 57 insertions(+), 4 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/prefetch-loop-arrays-1.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9cb013809eab..0f89e1e9a9a8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2006-09-17  Zdenek Dvorak <dvorakz@suse.cz>
+
+	PR tree-optimization/28887
+	* tree-ssa-loop-prefetch.c (analyze_ref): Strip nonaddressable
+	component parts from the reference.
+	(gather_memory_references_ref): Record the reference without the
+	nonaddressable component parts.
+
 2006-09-17  Steven Bosscher  <steven@gcc.gnu.org>
 
 	PR c/25993
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0864aeb373e2..ee17e1942461 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-09-17  Roger Sayle  <roger@eyesopen.com>
+
+	PR tree-optimization/28887
+	* gcc.dg/prefetch-loop-arrays-1.c: New test case.
+
 2006-09-16  Steven Bosscher  <steven@gcc.gnu.org>
 
 	PR c/25993
diff --git a/gcc/testsuite/gcc.dg/prefetch-loop-arrays-1.c b/gcc/testsuite/gcc.dg/prefetch-loop-arrays-1.c
new file mode 100644
index 000000000000..ba91d69650dc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/prefetch-loop-arrays-1.c
@@ -0,0 +1,36 @@
+/* PR tree-optimization/28887 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fprefetch-loop-arrays -w" } */
+/* { dg-options "-O2 -fprefetch-loop-arrays -march=i686 -msse -w" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+
+typedef unsigned long size_t;
+
+struct re_pattern_buffer
+{
+  size_t re_nsub;
+};
+
+typedef enum
+{
+  start_memory,
+} re_opcode_t;
+
+typedef union
+{
+  struct
+  {
+    unsigned matched_something:1;
+  } bits;
+} byte_register_info_type;
+
+void byte_re_match_2_internal (struct re_pattern_buffer *bufp)
+{
+  int mcnt;
+  size_t num_regs = bufp->re_nsub + 1;
+  byte_register_info_type *reg_info;
+  for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++)
+    {
+      ((reg_info[mcnt]).bits.matched_something) = 0;
+    }
+}
+
diff --git a/gcc/tree-ssa-loop-prefetch.c b/gcc/tree-ssa-loop-prefetch.c
index 9340bbb4029e..f9fe2d30c8a9 100644
--- a/gcc/tree-ssa-loop-prefetch.c
+++ b/gcc/tree-ssa-loop-prefetch.c
@@ -387,18 +387,20 @@ idx_analyze_ref (tree base, tree *index, void *data)
   return true;
 }
 
-/* Tries to express REF in shape &BASE + STEP * iter + DELTA, where DELTA and
+/* Tries to express REF_P in shape &BASE + STEP * iter + DELTA, where DELTA and
    STEP are integer constants and iter is number of iterations of LOOP.  The
-   reference occurs in statement STMT.  */
+   reference occurs in statement STMT.  Strips nonaddressable component
+   references from REF_P.  */
 
 static bool
-analyze_ref (struct loop *loop, tree ref, tree *base,
+analyze_ref (struct loop *loop, tree *ref_p, tree *base,
 	     HOST_WIDE_INT *step, HOST_WIDE_INT *delta,
 	     tree stmt)
 {
   struct ar_data ar_data;
   tree off;
   HOST_WIDE_INT bit_offset;
+  tree ref = *ref_p;
 
   *step = 0;
   *delta = 0;
@@ -408,6 +410,8 @@ analyze_ref (struct loop *loop, tree ref, tree *base,
       && DECL_NONADDRESSABLE_P (TREE_OPERAND (ref, 1)))
     ref = TREE_OPERAND (ref, 0);
 
+  *ref_p = ref;
+
   for (; TREE_CODE (ref) == COMPONENT_REF; ref = TREE_OPERAND (ref, 0))
     {
       off = DECL_FIELD_BIT_OFFSET (TREE_OPERAND (ref, 1));
@@ -436,7 +440,7 @@ gather_memory_references_ref (struct loop *loop, struct mem_ref_group **refs,
   HOST_WIDE_INT step, delta;
   struct mem_ref_group *agrp;
 
-  if (!analyze_ref (loop, ref, &base, &step, &delta, stmt))
+  if (!analyze_ref (loop, &ref, &base, &step, &delta, stmt))
     return;
 
   /* Now we know that REF = &BASE + STEP * iter + DELTA, where DELTA and STEP
-- 
GitLab