This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix PR tree-optimization/40254 - bug in data-refs analysis for basic blocks
- From: Ira Rosen <IRAR at il dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 28 May 2009 10:26:24 +0300
- Subject: [patch] Fix PR tree-optimization/40254 - bug in data-refs analysis for basic blocks
Hi,
This patch fixes a bug in data-refs analysis for basic blocks: the
data-ref's offset should be taken into account.
Bootstrapped with vectorization enabled on powerpc64-suse-linux, tested on
x86_64-suse-linux.
O.K. for mainline?
Thanks,
Ira
ChangeLog:
PR tree-optimization/40254
* tree-data-ref.c (dr_analyze_innermost): Take POFFSET into account
in analysis of basic blocks.
testsuite/ChangeLog:
PR tree-optimization/40254
* gcc.dg/vect/pr40254.c: New test.
Index: tree-data-ref.c
===================================================================
--- tree-data-ref.c (revision 147938)
+++ tree-data-ref.c (working copy)
@@ -718,17 +718,26 @@ dr_analyze_innermost (struct data_refere
base_iv.no_overflow = true;
}
- if (!poffset || !in_loop)
+ if (!poffset)
{
offset_iv.base = ssize_int (0);
offset_iv.step = ssize_int (0);
}
- else if (!simple_iv (loop, loop_containing_stmt (stmt),
- poffset, &offset_iv, false))
+ else
{
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file, "failed: evolution of offset is not
affine.\n");
- return false;
+ if (!in_loop)
+ {
+ offset_iv.base = poffset;
+ offset_iv.step = ssize_int (0);
+ }
+ else if (!simple_iv (loop, loop_containing_stmt (stmt),
+ poffset, &offset_iv, false))
+ {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, "failed: evolution of offset is not"
+ " affine.\n");
+ return false;
+ }
}
init = ssize_int (pbitpos / BITS_PER_UNIT);
Index: testsuite/gcc.dg/vect/pr40254.c
===================================================================
--- testsuite/gcc.dg/vect/pr40254.c (revision 0)
+++ testsuite/gcc.dg/vect/pr40254.c (revision 0)
@@ -0,0 +1,39 @@
+#include <stdlib.h>
+#include <stdarg.h>
+#include "tree-vect.h"
+
+struct s
+{
+ int *x;
+ int x1;
+ int x2;
+ int x3;
+ int *y;
+};
+
+struct s arr[64] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
+
+__attribute__ ((noinline)) void
+foo (int i, int *in_x, int *in_y)
+{
+ arr[i].x = in_x;
+ arr[i].y = in_y;
+}
+
+int
+main (void)
+{
+ int a, b;
+
+ check_vect ();
+
+ foo (5, &a, &b);
+
+ if (arr[5].x != &a || arr[5].y != &b)
+ abort ();
+
+ return 0;
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
+