public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix PR68445
Date: Mon, 23 Nov 2015 08:34:00 -0000	[thread overview]
Message-ID: <alpine.LSU.2.11.1511230933390.4884@t29.fhfr.qr> (raw)


The following fixes PR68445, SLP permutation being confused by
a permutation only using the "first" vector.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2015-11-23  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/68445
	* tree-vect-slp.c (vect_create_mask_and_perm): Properly use
	two different strides.

	* gcc.dg/vect/pr68445.c: New testcase.

Index: gcc/tree-vect-slp.c
===================================================================
*** gcc/tree-vect-slp.c	(revision 230653)
--- gcc/tree-vect-slp.c	(working copy)
*************** vect_create_mask_and_perm (gimple *stmt,
*** 3177,3186 ****
  {
    tree perm_dest;
    gimple *perm_stmt = NULL;
!   int i, stride;
    tree first_vec, second_vec, data_ref;
  
!   stride = SLP_TREE_NUMBER_OF_VEC_STMTS (node) / ncopies;
  
    /* Initialize the vect stmts of NODE to properly insert the generated
       stmts later.  */
--- 3206,3216 ----
  {
    tree perm_dest;
    gimple *perm_stmt = NULL;
!   int i, stride_in, stride_out;
    tree first_vec, second_vec, data_ref;
  
!   stride_out = SLP_TREE_NUMBER_OF_VEC_STMTS (node) / ncopies;
!   stride_in = dr_chain.length () / ncopies;
  
    /* Initialize the vect stmts of NODE to properly insert the generated
       stmts later.  */
*************** vect_create_mask_and_perm (gimple *stmt,
*** 3202,3211 ****
        vect_finish_stmt_generation (stmt, perm_stmt, gsi);
  
        /* Store the vector statement in NODE.  */
!       SLP_TREE_VEC_STMTS (node)[stride * i + vect_stmts_counter] = perm_stmt;
  
!       first_vec_indx += stride;
!       second_vec_indx += stride;
      }
  }
  
--- 3232,3242 ----
        vect_finish_stmt_generation (stmt, perm_stmt, gsi);
  
        /* Store the vector statement in NODE.  */
!       SLP_TREE_VEC_STMTS (node)[stride_out * i + vect_stmts_counter]
! 	= perm_stmt;
  
!       first_vec_indx += stride_in;
!       second_vec_indx += stride_in;
      }
  }
  
Index: gcc/testsuite/gcc.dg/vect/pr68445.c
===================================================================
*** gcc/testsuite/gcc.dg/vect/pr68445.c	(revision 0)
--- gcc/testsuite/gcc.dg/vect/pr68445.c	(working copy)
***************
*** 0 ****
--- 1,19 ----
+ /* { dg-do compile } */
+ /* { dg-require-effective-target vect_int } */
+ 
+ void IMB_double_fast_x (int *destf, int *dest, int y, int *p1f)
+ {
+   int i;
+   for (i = y; i > 0; i--)
+     {
+       *dest++ = 0;
+       destf[0] = destf[4] = p1f[0];
+       destf[1] = destf[5] = p1f[1];
+       destf[2] = destf[6] = p1f[2];
+       destf[3] = destf[7] = p1f[3];
+       destf += 8;
+       p1f += 4;
+     }
+ }
+ 
+ /* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */

                 reply	other threads:[~2015-11-23  8:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=alpine.LSU.2.11.1511230933390.4884@t29.fhfr.qr \
    --to=rguenther@suse.de \
    --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).