From: "Sjodin, Jan" <Jan.Sjodin@amd.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Improved dependence analysis
Date: Mon, 30 Jul 2007 18:20:00 -0000 [thread overview]
Message-ID: <7986CEFCE5C2954A88BEE2CAB6FAB374026FF635@SAUSEXMB2.amd.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 721 bytes --]
This patch improves the dependence analysis by allowing the extraction
of a constant offset from a base object when the base object address is
computed in a different statement. The patch passed bootstrap and make
check on amd64-linux.
2007-07-30 Jan Sjodin <jan.sjodin@amd.com>
* tree-data-ref.c
(split_constant_offset): Enable split_constant_offset to extract
constants from other statements.
* tree-vect-transform.c
(vect_create_addr_base_for_vector_ref): Generate data_ref_base
to a temp var. Force base_offset to be simple.
2007-07-30 Jan Sjodin <jan.sjodin@amd.com>
* gcc.dg/vect/vect-117.c: New test.
* gcc.dg/vect/vect-74.c: Enabled test
* gcc.dg/vect/vect-81.c: Enabled test
[-- Attachment #2: 001_base-offset.diff --]
[-- Type: application/octet-stream, Size: 5534 bytes --]
Index: trunk/gcc/testsuite/gcc.dg/vect/vect-117.c
===================================================================
--- trunk/gcc/testsuite/gcc.dg/vect/vect-117.c (revision 0)
+++ trunk/gcc/testsuite/gcc.dg/vect/vect-117.c (revision 0)
@@ -0,0 +1,63 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 5
+
+static int a[N][N] = {{ 1, 2, 3, 4, 5},
+ { 6, 7, 8, 9,10},
+ {11,12,13,14,15},
+ {16,17,18,19,20},
+ {21,22,23,24,25}};
+
+static int c[N][N] = {{ 1, 2, 3, 4, 5},
+ { 7, 9,11, 13,15},
+ {18,21,24,27,30},
+ {34,38,42,46,50},
+ {55,60,65,70,75}};
+
+volatile int foo;
+
+int main1 (int A[N][N])
+{
+
+ int i,j;
+
+ /* vectorizable */
+ for (i = 1; i < N; i++)
+ {
+ for (j = 0; j < N; j++)
+ {
+ A[i][j] = A[i-1][j] + A[i][j];
+ }
+ }
+
+ return 0;
+}
+
+int main (void)
+{
+ int i,j;
+
+ foo = 0;
+ main1 (a);
+
+ /* check results: */
+
+ for (i = 0; i < N; i++)
+ {
+ for (j = 0; j < N; j++)
+ {
+ if (a[i][j] != c[i][j])
+ abort();
+ }
+ }
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 0 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
Index: trunk/gcc/testsuite/gcc.dg/vect/vect-80.c
===================================================================
--- trunk/gcc/testsuite/gcc.dg/vect/vect-80.c (revision 126953)
+++ trunk/gcc/testsuite/gcc.dg/vect/vect-80.c (working copy)
@@ -47,7 +47,7 @@ int main (void)
all three accesses (peeling to align the store will not force the
two loads to be aligned). */
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
/* Uncomment when this testcase gets vectorized again:
dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { xfail vect_no_align } }
dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail vect_no_align } }
Index: trunk/gcc/testsuite/gcc.dg/vect/vect-74.c
===================================================================
--- trunk/gcc/testsuite/gcc.dg/vect/vect-74.c (revision 126953)
+++ trunk/gcc/testsuite/gcc.dg/vect/vect-74.c (working copy)
@@ -43,7 +43,7 @@ int main (void)
}
/* Xfail until handling restrict is refined. See pr29145 */
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
/* Uncomment when this testcase gets vectorized again:
dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 3 "vect" { target vect_no_align } }
dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { xfail vect_no_align } }
Index: trunk/gcc/tree-data-ref.c
===================================================================
--- trunk/gcc/tree-data-ref.c (revision 126953)
+++ trunk/gcc/tree-data-ref.c (working copy)
@@ -565,6 +565,27 @@ split_constant_offset (tree exp, tree *v
return;
}
+ case SSA_NAME:
+ {
+ tree def_stmt = SSA_NAME_DEF_STMT (exp);
+ if (TREE_CODE (def_stmt) == GIMPLE_MODIFY_STMT)
+ {
+ tree def_stmt_rhs = GIMPLE_STMT_OPERAND (def_stmt, 1);
+
+ if (!TREE_SIDE_EFFECTS (def_stmt_rhs)
+ && EXPR_P (def_stmt_rhs)
+ && !REFERENCE_CLASS_P (def_stmt_rhs))
+ {
+ split_constant_offset (def_stmt_rhs, &var0, &off0);
+ var0 = fold_convert (type, var0);
+ *var = var0;
+ *off = off0;
+ return;
+ }
+ }
+ break;
+ }
+
default:
break;
}
Index: trunk/gcc/tree-vect-transform.c
===================================================================
--- trunk/gcc/tree-vect-transform.c (revision 126953)
+++ trunk/gcc/tree-vect-transform.c (working copy)
@@ -711,21 +711,32 @@ vect_create_addr_base_for_vector_ref (tr
{
stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
struct data_reference *dr = STMT_VINFO_DATA_REF (stmt_info);
- tree data_ref_base = unshare_expr (DR_BASE_ADDRESS (dr));
- tree base_name = build_fold_indirect_ref (data_ref_base);
+ tree data_ref_base_expr = unshare_expr (DR_BASE_ADDRESS (dr));
+ tree base_name = build_fold_indirect_ref (data_ref_base_expr);
+ tree data_ref_base_var;
+ tree data_ref_base;
+ tree new_base_stmt;
tree vec_stmt;
tree addr_base, addr_expr;
tree dest, new_stmt;
tree base_offset = unshare_expr (DR_OFFSET (dr));
tree init = unshare_expr (DR_INIT (dr));
tree vect_ptr_type, addr_expr2;
+
+
+ /* Create data_ref_base */
+ data_ref_base_var = create_tmp_var (TREE_TYPE (data_ref_base_expr), "batmp");
+ add_referenced_var (data_ref_base_var);
+ data_ref_base = force_gimple_operand (data_ref_base_expr, &new_base_stmt,
+ true, data_ref_base_var);
+ append_to_statement_list_force (new_base_stmt, new_stmt_list);
/* Create base_offset */
base_offset = size_binop (PLUS_EXPR, base_offset, init);
base_offset = fold_convert (sizetype, base_offset);
dest = create_tmp_var (TREE_TYPE (base_offset), "base_off");
add_referenced_var (dest);
- base_offset = force_gimple_operand (base_offset, &new_stmt, false, dest);
+ base_offset = force_gimple_operand (base_offset, &new_stmt, true, dest);
append_to_statement_list_force (new_stmt, new_stmt_list);
if (offset)
next reply other threads:[~2007-07-30 18:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-30 18:20 Sjodin, Jan [this message]
2007-07-30 18:49 ` Daniel Berlin
2007-07-31 7:15 ` Sjodin, Jan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7986CEFCE5C2954A88BEE2CAB6FAB374026FF635@SAUSEXMB2.amd.com \
--to=jan.sjodin@amd.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).