[PATCH] vect: Init inside_cost in vect_model_reduction_cost

Kewen.Lin linkw@linux.ibm.com
Thu Mar 25 06:04:24 GMT 2021


Hi,

I happened to find this possible use of uninitialized inside_cost during
checking the cost for reduction.  Before r11-6587, all the if/else if/else
arms will assign values to inside_cost, so it was fine.  But from r11-6587
the else path won't assign any more, it leads the inside_cost possibly
uninitialized for later use.  Note that it won't have any functionality
issues, just could show one unreasonable cost in dump file.

This is a trivial fix and I guess it can be counted as obvious, but
I'm not sure if it's ok in stage 4.  So is it ok for trunk?


BR,
Kewen
-----
gcc/ChangeLog:

	* tree-vect-loop.c (vect_model_reduction_cost): Init inside_cost.

diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 3e973e774af..38d96fc1634 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -4465,7 +4465,7 @@ vect_model_reduction_cost (loop_vec_info loop_vinfo,
                            vect_reduction_type reduction_type,
                            int ncopies, stmt_vector_for_cost *cost_vec)
 {
-  int prologue_cost = 0, epilogue_cost = 0, inside_cost;
+  int prologue_cost = 0, epilogue_cost = 0, inside_cost = 0;
   enum tree_code code;
   optab optab;
   tree vectype;






More information about the Gcc-patches mailing list