This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR46184


This fixes us not being able to compute the incoming vector type
for a reduction where the other def is external.  Fixed by also
trying the reduction variable itself (which surprisingly isn't
working always, hmm).

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

2010-11-02  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/46184
	* tree-vect-loop.c (vectorizable_reduction): Try to obtain the
	input vector type from the reduction operand as well.

	* gcc.dg/pr46184.c: New testcase.

Index: gcc/tree-vect-loop.c
===================================================================
*** gcc/tree-vect-loop.c	(revision 166172)
--- gcc/tree-vect-loop.c	(working copy)
*************** vectorizable_reduction (gimple stmt, gim
*** 3908,3914 ****
    VEC (tree, heap) *vec_oprnds0 = NULL, *vec_oprnds1 = NULL, *vect_defs = NULL;
    VEC (gimple, heap) *phis = NULL;
    int vec_num;
!   tree def0, def1;
  
    if (nested_in_vect_loop_p (loop, stmt))
      {
--- 3908,3914 ----
    VEC (tree, heap) *vec_oprnds0 = NULL, *vec_oprnds1 = NULL, *vect_defs = NULL;
    VEC (gimple, heap) *phis = NULL;
    int vec_num;
!   tree def0, def1, tem;
  
    if (nested_in_vect_loop_p (loop, stmt))
      {
*************** vectorizable_reduction (gimple stmt, gim
*** 3999,4006 ****
       reduction variable.  */
    for (i = 0; i < op_type-1; i++)
      {
-       tree tem;
- 
        /* The condition of COND_EXPR is checked in vectorizable_condition().  */
        if (i == 0 && code == COND_EXPR)
          continue;
--- 3999,4004 ----
*************** vectorizable_reduction (gimple stmt, gim
*** 4025,4032 ****
          }
      }
  
!   is_simple_use = vect_is_simple_use (ops[i], loop_vinfo, NULL, &def_stmt,
! 				      &def, &dt);
    gcc_assert (is_simple_use);
    gcc_assert (dt == vect_reduction_def
                || dt == vect_nested_cycle
--- 4023,4032 ----
          }
      }
  
!   is_simple_use = vect_is_simple_use_1 (ops[i], loop_vinfo, NULL, &def_stmt,
! 					&def, &dt, &tem);
!   if (!vectype_in)
!     vectype_in = tem;
    gcc_assert (is_simple_use);
    gcc_assert (dt == vect_reduction_def
                || dt == vect_nested_cycle
Index: gcc/testsuite/gcc.dg/pr46184.c
===================================================================
*** gcc/testsuite/gcc.dg/pr46184.c	(revision 0)
--- gcc/testsuite/gcc.dg/pr46184.c	(revision 0)
***************
*** 0 ****
--- 1,18 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O -ftree-vectorize -fno-tree-copy-prop -fno-tree-dce" } */
+ 
+ extern int A[], B[];
+ 
+ void
+ foo (int z)
+ {
+   int j, i;
+   for (j = 0; j < 32; j++)
+     {
+       int curr_a = A[0];
+       for (i = 0; i < 16; i++)
+ 	curr_a = A[i] ? curr_a : z;
+       B[j] = curr_a;
+     }
+ }
+ 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]