public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Improved dependence analysis
@ 2007-07-30 18:20 Sjodin, Jan
  2007-07-30 18:49 ` Daniel Berlin
  0 siblings, 1 reply; 3+ messages in thread
From: Sjodin, Jan @ 2007-07-30 18:20 UTC (permalink / raw)
  To: gcc-patches

[-- 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)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Improved dependence analysis
  2007-07-30 18:20 [PATCH] Improved dependence analysis Sjodin, Jan
@ 2007-07-30 18:49 ` Daniel Berlin
  2007-07-31  7:15   ` Sjodin, Jan
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Berlin @ 2007-07-30 18:49 UTC (permalink / raw)
  To: Sjodin, Jan; +Cc: gcc-patches

On 7/30/07, Sjodin, Jan <Jan.Sjodin@amd.com> wrote:
> 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.
>

This patch is ok.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] Improved dependence analysis
  2007-07-30 18:49 ` Daniel Berlin
@ 2007-07-31  7:15   ` Sjodin, Jan
  0 siblings, 0 replies; 3+ messages in thread
From: Sjodin, Jan @ 2007-07-31  7:15 UTC (permalink / raw)
  To: Daniel Berlin; +Cc: gcc-patches

Committed revision 127080.

Thanks,
Jan

> -----Original Message-----
> From: Daniel Berlin [mailto:dberlin@dberlin.org] 
> Sent: Monday, July 30, 2007 1:35 PM
> To: Sjodin, Jan
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [PATCH] Improved dependence analysis
> 
> On 7/30/07, Sjodin, Jan <Jan.Sjodin@amd.com> wrote:
> > 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.
> >
> 
> This patch is ok.
> 
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-07-31  5:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-30 18:20 [PATCH] Improved dependence analysis Sjodin, Jan
2007-07-30 18:49 ` Daniel Berlin
2007-07-31  7:15   ` Sjodin, Jan

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).