diff mbox

[14/14,Vectorizer] Tidy up vect_create_epilog / use_scalar_result

Message ID 541AD488.9060900@arm.com
State New
Headers show

Commit Message

Alan Lawrence Sept. 18, 2014, 12:48 p.m. UTC
Following earlier patches, vect_create_epilog_for_reduction contains exactly one 
case where extract_scalar_result==true. Hence, move the code 'if 
(extract_scalar_result)' there, and tidy-up/remove some variables.

bootstrapped on x86_64-none-linux-gnu + check-gcc + check-g++.

gcc/ChangeLog:

	* tree-vect-loop.c (vect_create_epilog_for_reduction): Move code for
	'if (extract_scalar_result)' to the only place that it is true.

Comments

Richard Biener Sept. 22, 2014, 10:53 a.m. UTC | #1
On Thu, Sep 18, 2014 at 2:48 PM, Alan Lawrence <alan.lawrence@arm.com> wrote:
> Following earlier patches, vect_create_epilog_for_reduction contains exactly
> one case where extract_scalar_result==true. Hence, move the code 'if
> (extract_scalar_result)' there, and tidy-up/remove some variables.
>
> bootstrapped on x86_64-none-linux-gnu + check-gcc + check-g++.

Ok.

Thanks,
Richard.

> gcc/ChangeLog:
>
>         * tree-vect-loop.c (vect_create_epilog_for_reduction): Move code for
>         'if (extract_scalar_result)' to the only place that it is true.
Alan Lawrence Nov. 14, 2014, 5:21 p.m. UTC | #2
After recent updates, tree-vect-loop.c is in the same state as when this cleanup 
patch was first written and approved, so I've just pushed it as r/217580.

Cheers,
Alan

Richard Biener wrote:
> On Thu, Sep 18, 2014 at 2:48 PM, Alan Lawrence <alan.lawrence@arm.com> wrote:
>> Following earlier patches, vect_create_epilog_for_reduction contains exactly
>> one case where extract_scalar_result==true. Hence, move the code 'if
>> (extract_scalar_result)' there, and tidy-up/remove some variables.
>>
>> bootstrapped on x86_64-none-linux-gnu + check-gcc + check-g++.
> 
> Ok.
> 
> Thanks,
> Richard.
> 
>> gcc/ChangeLog:
>>
>>         * tree-vect-loop.c (vect_create_epilog_for_reduction): Move code for
>>         'if (extract_scalar_result)' to the only place that it is true.
>
diff mbox

Patch

diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 016e2c1fc839fc4d1c97caaa38064fb8bbb510d8..62b279e4d29d1fdfbfbd4e606fc8be9d608d3707 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -3867,7 +3867,6 @@  vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple stmt,
   tree orig_name, scalar_result;
   imm_use_iterator imm_iter, phi_imm_iter;
   use_operand_p use_p, phi_use_p;
-  bool extract_scalar_result = false;
   gimple use_stmt, orig_stmt, reduction_phi = NULL;
   bool nested_in_vect_loop = false;
   auto_vec<gimple> new_phis;
@@ -4235,6 +4234,8 @@  vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple stmt,
                   Create:  va = vop <va, va'>
                 }  */
 
+          tree rhs;
+
           if (dump_enabled_p ())
             dump_printf_loc (MSG_NOTE, vect_location,
 			     "Reduce using vector shifts\n");
@@ -4260,7 +4261,20 @@  vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple stmt,
               gsi_insert_before (&exit_gsi, epilog_stmt, GSI_SAME_STMT);
             }
 
-          extract_scalar_result = true;
+	  /* 2.4  Extract the final scalar result.  Create:
+	     s_out3 = extract_field <v_out2, bitpos>  */
+
+	  if (dump_enabled_p ())
+	    dump_printf_loc (MSG_NOTE, vect_location,
+			     "extract scalar result\n");
+
+	  rhs = build3 (BIT_FIELD_REF, scalar_type, new_temp,
+			bitsize, bitsize_zero_node);
+	  epilog_stmt = gimple_build_assign (new_scalar_dest, rhs);
+	  new_temp = make_ssa_name (new_scalar_dest, epilog_stmt);
+	  gimple_assign_set_lhs (epilog_stmt, new_temp);
+	  gsi_insert_before (&exit_gsi, epilog_stmt, GSI_SAME_STMT);
+	  scalar_results.safe_push (new_temp);
         }
       else
         {
@@ -4355,30 +4369,8 @@  vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple stmt,
           else
             /* Not SLP - we have one scalar to keep in SCALAR_RESULTS.  */
             scalar_results.safe_push (new_temp);
-
-          extract_scalar_result = false;
         }
     }
-
-  /* 2.4  Extract the final scalar result.  Create:
-          s_out3 = extract_field <v_out2, bitpos>  */
-
-  if (extract_scalar_result)
-    {
-      tree rhs;
-
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_NOTE, vect_location,
-			 "extract scalar result\n");
-
-      rhs = build3 (BIT_FIELD_REF, scalar_type,
-		    new_temp, bitsize, bitsize_zero_node);
-      epilog_stmt = gimple_build_assign (new_scalar_dest, rhs);
-      new_temp = make_ssa_name (new_scalar_dest, epilog_stmt);
-      gimple_assign_set_lhs (epilog_stmt, new_temp);
-      gsi_insert_before (&exit_gsi, epilog_stmt, GSI_SAME_STMT);
-      scalar_results.safe_push (new_temp);
-    }
   
 vect_finalize_reduction: