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 PR50328


This fixes our inability to handle reductions with a constant
or a parameter.

Bootstrapped and tested on x86_64-unknown-linux-gnu, the testcase
requires all the previously posted patches from today to not ICE
and pass though.

Richard.

2011-09-09  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/50328
	* tree-vect-loop.c (vect_is_simple_reduction_1): Allow one
	constant or default-def operand.

	* gcc.dg/vect/fast-math-vect-outer-7.c: New testcase.

Index: gcc/tree-vect-loop.c
===================================================================
*** gcc/tree-vect-loop.c	(revision 178719)
--- gcc/tree-vect-loop.c	(working copy)
*************** vect_is_simple_reduction_1 (loop_vec_inf
*** 2149,2155 ****
        op1 = gimple_assign_rhs1 (def_stmt);
        op2 = gimple_assign_rhs2 (def_stmt);
  
!       if (TREE_CODE (op1) != SSA_NAME || TREE_CODE (op2) != SSA_NAME)
          {
            if (vect_print_dump_info (REPORT_DETAILS))
  	    report_vect_op (def_stmt, "reduction: uses not ssa_names: ");
--- 2149,2155 ----
        op1 = gimple_assign_rhs1 (def_stmt);
        op2 = gimple_assign_rhs2 (def_stmt);
  
!       if (TREE_CODE (op1) != SSA_NAME && TREE_CODE (op2) != SSA_NAME)
          {
            if (vect_print_dump_info (REPORT_DETAILS))
  	    report_vect_op (def_stmt, "reduction: uses not ssa_names: ");
*************** vect_is_simple_reduction_1 (loop_vec_inf
*** 2255,2261 ****
      def2 = SSA_NAME_DEF_STMT (op2);
  
    if (code != COND_EXPR
!       && (!def1 || !def2 || gimple_nop_p (def1) || gimple_nop_p (def2)))
      {
        if (vect_print_dump_info (REPORT_DETAILS))
  	report_vect_op (def_stmt, "reduction: no defs for operands: ");
--- 2255,2261 ----
      def2 = SSA_NAME_DEF_STMT (op2);
  
    if (code != COND_EXPR
!       && ((!def1 || gimple_nop_p (def1)) && (!def2 || gimple_nop_p (def2))))
      {
        if (vect_print_dump_info (REPORT_DETAILS))
  	report_vect_op (def_stmt, "reduction: no defs for operands: ");
*************** vect_is_simple_reduction_1 (loop_vec_inf
*** 2268,2273 ****
--- 2268,2274 ----
  
    if (def2 && def2 == phi
        && (code == COND_EXPR
+ 	  || !def1 || gimple_nop_p (def1)
            || (def1 && flow_bb_inside_loop_p (loop, gimple_bb (def1))
                && (is_gimple_assign (def1)
  		  || is_gimple_call (def1)
*************** vect_is_simple_reduction_1 (loop_vec_inf
*** 2285,2290 ****
--- 2286,2292 ----
  
    if (def1 && def1 == phi
        && (code == COND_EXPR
+ 	  || !def2 || gimple_nop_p (def2)
            || (def2 && flow_bb_inside_loop_p (loop, gimple_bb (def2))
   	      && (is_gimple_assign (def2)
  		  || is_gimple_call (def2)
Index: gcc/testsuite/gcc.dg/vect/fast-math-vect-outer-7.c
===================================================================
*** gcc/testsuite/gcc.dg/vect/fast-math-vect-outer-7.c	(revision 0)
--- gcc/testsuite/gcc.dg/vect/fast-math-vect-outer-7.c	(revision 0)
***************
*** 0 ****
--- 1,23 ----
+ /* { dg-do compile } */
+ /* { dg-require-effective-target vect_float } */
+ 
+ float dvec[256];
+ 
+ void test1 (float x)
+ {
+   long i, j;
+   for (i = 0; i < 256; ++i)
+     for (j = 0; j < 131072; ++j)
+       dvec[i] *= x;
+ }
+ 
+ void test2 (float x)
+ {
+   long i, j;
+   for (i = 0; i < 256; ++i)
+     for (j = 0; j < 131072; ++j)
+       dvec[i] *= 1.001f;
+ }
+ 
+ /* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 2 "vect" } } */
+ /* { dg-final { cleanup-tree-dump "vect" } } */


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