My earlier patch to avoid dead code generation for vectorized
invariant loops breaks re-align load targets as the setup is
still carried out for them.

Fixed as follows, bootstrapped and tested on x86_64-unknown-linux-gnu
and with a ppc cross.

Committed.

Richard.

2013-01-03  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/55857
        * tree-vect-stmts.c (vectorizable_load): Do not setup
        re-alignment for invariant loads.

        * gcc.dg/vect/pr55857-1.c: New testcase.
        * gcc.dg/vect/pr55857-2.c: Likewise.

Index: gcc/tree-vect-stmts.c
===================================================================
*** gcc/tree-vect-stmts.c       (revision 194844)
--- gcc/tree-vect-stmts.c       (working copy)
*************** vectorizable_load (gimple stmt, gimple_s
*** 4927,4933 ****
  
    if ((alignment_support_scheme == dr_explicit_realign_optimized
         || alignment_support_scheme == dr_explicit_realign)
!       && !compute_in_loop)
      {
        msq = vect_setup_realignment (first_stmt, gsi, &realignment_token,
                                    alignment_support_scheme, NULL_TREE,
--- 4927,4934 ----
  
    if ((alignment_support_scheme == dr_explicit_realign_optimized
         || alignment_support_scheme == dr_explicit_realign)
!       && !compute_in_loop
!       && !integer_zerop (DR_STEP (dr)))
      {
        msq = vect_setup_realignment (first_stmt, gsi, &realignment_token,
                                    alignment_support_scheme, NULL_TREE,
Index: gcc/testsuite/gcc.dg/vect/pr55857-1.c
===================================================================
*** gcc/testsuite/gcc.dg/vect/pr55857-1.c       (revision 0)
--- gcc/testsuite/gcc.dg/vect/pr55857-1.c       (working copy)
***************
*** 0 ****
--- 1,17 ----
+ /* { dg-do compile } */
+ 
+ void 
+ foo (int *data, unsigned len, const int qlp_coeff[], int lp, int residual[])
+ {
+   int i;
+   int sum;
+   for(i = 0; i < (int)len; i++)
+     {     
+       sum = 0;   
+       sum += qlp_coeff[1] * data[i-2];   
+       sum += qlp_coeff[0] * data[i-1];   
+       residual[i] = data[i] - (sum >> lp);
+     }    
+ }
+ 
+ /* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/pr55857-2.c
===================================================================
*** gcc/testsuite/gcc.dg/vect/pr55857-2.c       (revision 0)
--- gcc/testsuite/gcc.dg/vect/pr55857-2.c       (working copy)
***************
*** 0 ****
--- 1,21 ----
+ /* { dg-do compile } */
+ 
+ void foo (int *data, unsigned len, const int qlp_coeff[],
+         unsigned order, int lp, int residual[])
+ {
+   int i;
+   int sum;
+   if(order == 2)
+     for(i = 0; i < (int)len; i++)
+       {
+       sum = 0;
+       sum += qlp_coeff[1] * data[i-2]; 
+       sum += qlp_coeff[0] * data[i-1];
+       residual[i] = data[i] - (sum >> lp);
+       }
+   else
+     for(i = 0; i < (int)len; i++)  
+       residual[i] = data[i] - ((qlp_coeff[0] * data[i-1]) >> lp);
+ }
+ 
+ /* { dg-final { cleanup-tree-dump "vect" } } */

Reply via email to