public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Google] Port patch r215585 to Google/4.9 branch
@ 2014-12-16 19:32 Carrot Wei
  2014-12-16 19:34 ` Xinliang David Li
  0 siblings, 1 reply; 3+ messages in thread
From: Carrot Wei @ 2014-12-16 19:32 UTC (permalink / raw)
  To: gcc-patches, David Li, Doug Kwan

[-- Attachment #1: Type: text/plain, Size: 310 bytes --]

Hi

In Google application we hit the same problem as
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63341, so we also need
the patch r215585 for Google/4.9 branch.

It passed following tests:
bootstrap and regression test on x86-64.
regression test on ppc.

Google reference 18687126.

OK for Google/4.9 branch?

[-- Attachment #2: patch --]
[-- Type: application/octet-stream, Size: 7452 bytes --]

Index: testsuite/gcc.dg/vect/pr63341-1.c
===================================================================
--- testsuite/gcc.dg/vect/pr63341-1.c	(revision 0)
+++ testsuite/gcc.dg/vect/pr63341-1.c	(working copy)
@@ -0,0 +1,32 @@
+/* PR tree-optimization/63341 */
+/* { dg-do run } */
+
+#include "tree-vect.h"
+
+typedef union U { unsigned short s; unsigned char c; } __attribute__((packed)) U;
+struct S { char e __attribute__((aligned (64))); U s[32]; };
+struct S t = {0, {{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}, {26}, {27}, {28}, {29}, {30}, {31}, {32}}};
+unsigned short d[32] = { 1 };
+
+__attribute__((noinline, noclone)) void
+foo ()
+{
+  int i;
+  for (i = 0; i < 32; i++)
+    d[i] = t.s[i].s;
+  if (__builtin_memcmp (d, t.s, sizeof d))
+    abort ();
+}
+
+int
+main ()
+{
+  check_vect ();
+  foo ();
+  return 0;
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/pr63341-2.c
===================================================================
--- testsuite/gcc.dg/vect/pr63341-2.c	(revision 0)
+++ testsuite/gcc.dg/vect/pr63341-2.c	(working copy)
@@ -0,0 +1,35 @@
+/* PR tree-optimization/63341 */
+/* { dg-do run } */
+
+#include "tree-vect.h"
+
+typedef union U { unsigned short s; unsigned char c; } __attribute__((packed)) U;
+struct S { char e __attribute__((aligned (64))); U s[32]; };
+struct S t = {0, {{0x5010}, {0x5111}, {0x5212}, {0x5313}, {0x5414}, {0x5515}, {0x5616}, {0x5717},
+		  {0x5818}, {0x5919}, {0x5a1a}, {0x5b1b}, {0x5c1c}, {0x5d1d}, {0x5e1e}, {0x5f1f},
+		  {0x6020}, {0x6121}, {0x6222}, {0x6323}, {0x6424}, {0x6525}, {0x6626}, {0x6727},
+		  {0x6828}, {0x6929}, {0x6a2a}, {0x6b2b}, {0x6c2c}, {0x6d2d}, {0x6e2e}, {0x6f2f}}};
+unsigned short d[32] = { 1 };
+
+__attribute__((noinline, noclone)) void
+foo ()
+{
+  int i;
+  for (i = 0; i < 32; i++)
+    d[i] = t.s[i].s + 4;
+  for (i = 0; i < 32; i++)
+    if (d[i] != t.s[i].s + 4)
+      abort ();
+    else
+      asm volatile ("" : : : "memory");
+}
+
+int
+main ()
+{
+  check_vect ();
+  foo ();
+  return 0;
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: tree-vect-data-refs.c
===================================================================
--- tree-vect-data-refs.c	(revision 218769)
+++ tree-vect-data-refs.c	(working copy)
@@ -3841,6 +3841,9 @@
 	    is as follows:
 	    if LOOP=i_loop:	&in		(relative to i_loop)
 	    if LOOP=j_loop: 	&in+i*2B	(relative to j_loop)
+   BYTE_OFFSET: Optional, defaulted to NULL.  If supplied, it is added to the
+	    initial address.  Unlike OFFSET, which is number of elements to
+	    be added, BYTE_OFFSET is measured in bytes.
 
    Output:
    1. Return an SSA_NAME whose value is the address of the memory location of
@@ -3854,7 +3857,8 @@
 vect_create_addr_base_for_vector_ref (gimple stmt,
 				      gimple_seq *new_stmt_list,
 				      tree offset,
-				      struct loop *loop)
+				      struct loop *loop,
+				      tree byte_offset)
 {
   stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
   struct data_reference *dr = STMT_VINFO_DATA_REF (stmt_info);
@@ -3908,6 +3912,13 @@
 				 base_offset, offset);
     }
 
+  if (byte_offset)
+    {
+      byte_offset = fold_convert (sizetype, byte_offset);
+      base_offset = fold_build2 (PLUS_EXPR, sizetype,
+				 base_offset, byte_offset);
+    }
+
   /* base + base_offset */
   if (loop_vinfo)
     addr_base = fold_build_pointer_plus (data_ref_base, base_offset);
@@ -3964,6 +3975,10 @@
    5. BSI: location where the new stmts are to be placed if there is no loop
    6. ONLY_INIT: indicate if ap is to be updated in the loop, or remain
         pointing to the initial address.
+   7. BYTE_OFFSET (optional, defaults to NULL): a byte offset to be added
+        to the initial address accessed by the data-ref in STMT.  This is
+        similar to OFFSET, but OFFSET is counted in elements, while BYTE_OFFSET
+        in bytes.
 
    Output:
    1. Declare a new ptr to vector_type, and have it point to the base of the
@@ -3977,6 +3992,8 @@
          initial_address = &a[init];
       if OFFSET is supplied:
          initial_address = &a[init + OFFSET];
+      if BYTE_OFFSET is supplied:
+         initial_address = &a[init] + BYTE_OFFSET;
 
       Return the initial_address in INITIAL_ADDRESS.
 
@@ -3994,7 +4011,7 @@
 vect_create_data_ref_ptr (gimple stmt, tree aggr_type, struct loop *at_loop,
 			  tree offset, tree *initial_address,
 			  gimple_stmt_iterator *gsi, gimple *ptr_incr,
-			  bool only_init, bool *inv_p)
+			  bool only_init, bool *inv_p, tree byte_offset)
 {
   const char *base_name;
   stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
@@ -4137,10 +4154,10 @@
   /* (2) Calculate the initial address of the aggregate-pointer, and set
      the aggregate-pointer to point to it before the loop.  */
 
-  /* Create: (&(base[init_val+offset]) in the loop preheader.  */
+  /* Create: (&(base[init_val+offset]+byte_offset) in the loop preheader.  */
 
   new_temp = vect_create_addr_base_for_vector_ref (stmt, &new_stmt_list,
-                                                   offset, loop);
+                                                   offset, loop, byte_offset);
   if (new_stmt_list)
     {
       if (pe)
Index: tree-vect-stmts.c
===================================================================
--- tree-vect-stmts.c	(revision 218769)
+++ tree-vect-stmts.c	(working copy)
@@ -5600,6 +5600,7 @@
   int i, j, group_size, group_gap;
   tree msq = NULL_TREE, lsq;
   tree offset = NULL_TREE;
+  tree byte_offset = NULL_TREE;
   tree realignment_token = NULL_TREE;
   gimple phi = NULL;
   vec<tree> dr_chain = vNULL;
@@ -6261,7 +6262,8 @@
       if (alignment_support_scheme == dr_explicit_realign_optimized)
 	{
 	  phi = SSA_NAME_DEF_STMT (msq);
-	  offset = size_int (TYPE_VECTOR_SUBPARTS (vectype) - 1);
+	  byte_offset = size_binop (MINUS_EXPR, TYPE_SIZE_UNIT (vectype),
+				    size_one_node);
 	}
     }
   else
@@ -6302,7 +6304,8 @@
 	    dataref_ptr
 	      = vect_create_data_ref_ptr (first_stmt, aggr_type, at_loop,
 					  offset, &dummy, gsi, &ptr_incr,
-					  simd_lane_access_p, &inv_p);
+					  simd_lane_access_p, &inv_p,
+					  byte_offset);
 	}
       else if (dataref_offset)
 	dataref_offset = int_const_binop (PLUS_EXPR, dataref_offset,
Index: tree-vectorizer.h
===================================================================
--- tree-vectorizer.h	(revision 218769)
+++ tree-vectorizer.h	(working copy)
@@ -1061,7 +1061,8 @@
 				    unsigned *);
 extern tree vect_create_data_ref_ptr (gimple, tree, struct loop *, tree,
 				      tree *, gimple_stmt_iterator *,
-				      gimple *, bool, bool *);
+				      gimple *, bool, bool *,
+				      tree = NULL_TREE);
 extern tree bump_vector_ptr (tree, gimple, gimple_stmt_iterator *, gimple, tree);
 extern tree vect_create_destination_var (tree, tree);
 extern bool vect_grouped_store_supported (tree, unsigned HOST_WIDE_INT);
@@ -1078,7 +1079,8 @@
 extern void vect_record_grouped_load_vectors (gimple, vec<tree> );
 extern tree vect_get_new_vect_var (tree, enum vect_var_kind, const char *);
 extern tree vect_create_addr_base_for_vector_ref (gimple, gimple_seq *,
-                                                  tree, struct loop *);
+						  tree, struct loop *,
+						  tree = NULL_TREE);
 
 /* In tree-vect-loop.c.  */
 /* FORNOW: Used in tree-parloops.c.  */

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

* Re: [Google] Port patch r215585 to Google/4.9 branch
  2014-12-16 19:32 [Google] Port patch r215585 to Google/4.9 branch Carrot Wei
@ 2014-12-16 19:34 ` Xinliang David Li
  2014-12-16 19:58   ` Carrot Wei
  0 siblings, 1 reply; 3+ messages in thread
From: Xinliang David Li @ 2014-12-16 19:34 UTC (permalink / raw)
  To: Carrot Wei; +Cc: gcc-patches, Doug Kwan

The fix is already in upstream gcc-4.9 branch? If yes, we just need a merge.

David

On Tue, Dec 16, 2014 at 11:30 AM, Carrot Wei <carrot@google.com> wrote:
> Hi
>
> In Google application we hit the same problem as
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63341, so we also need
> the patch r215585 for Google/4.9 branch.
>
> It passed following tests:
> bootstrap and regression test on x86-64.
> regression test on ppc.
>
> Google reference 18687126.
>
> OK for Google/4.9 branch?

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

* Re: [Google] Port patch r215585 to Google/4.9 branch
  2014-12-16 19:34 ` Xinliang David Li
@ 2014-12-16 19:58   ` Carrot Wei
  0 siblings, 0 replies; 3+ messages in thread
From: Carrot Wei @ 2014-12-16 19:58 UTC (permalink / raw)
  To: Xinliang David Li; +Cc: gcc-patches, Doug Kwan

Yes, it has been long time since last merge, so it is good idea to do
another merge.

On Tue, Dec 16, 2014 at 11:32 AM, Xinliang David Li <davidxl@google.com> wrote:
> The fix is already in upstream gcc-4.9 branch? If yes, we just need a merge.
>
> David
>
> On Tue, Dec 16, 2014 at 11:30 AM, Carrot Wei <carrot@google.com> wrote:
>> Hi
>>
>> In Google application we hit the same problem as
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63341, so we also need
>> the patch r215585 for Google/4.9 branch.
>>
>> It passed following tests:
>> bootstrap and regression test on x86-64.
>> regression test on ppc.
>>
>> Google reference 18687126.
>>
>> OK for Google/4.9 branch?

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

end of thread, other threads:[~2014-12-16 19:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-16 19:32 [Google] Port patch r215585 to Google/4.9 branch Carrot Wei
2014-12-16 19:34 ` Xinliang David Li
2014-12-16 19:58   ` Carrot Wei

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