re PR tree-optimization/79340 (Memory leaks in tree-vect-slp.c)
authorJakub Jelinek <jakub@redhat.com>
Fri, 3 Feb 2017 22:36:29 +0000 (23:36 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 3 Feb 2017 22:36:29 +0000 (23:36 +0100)
PR tree-optimization/79340
* tree-vect-loop.c (vectorizable_reduction): Release
vec_defs elements after safe_splicing them into other vectors.
Formatting fixes.

From-SVN: r245171

gcc/ChangeLog
gcc/tree-vect-loop.c

index 70e37c17d03a1518ca07fbc37a1da93db7ad788f..5bfbff585a51c36a3d7c31fae06fb3c3c0c2f3f2 100644 (file)
@@ -1,5 +1,10 @@
 2017-02-03  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/79340
+       * tree-vect-loop.c (vectorizable_reduction): Release
+       vec_defs elements after safe_splicing them into other vectors.
+       Formatting fixes.
+
        PR tree-optimization/79327
        * gimple-ssa-sprintf.c (adjust_range_for_overflow): If returning
        true, always set *argmin and *argmax to TYPE_{MIN,MAX}_VALUE of
index c55be9f7febff0e08de4648b5fb43591ec2f735f..f9b3f5432d8631eac5c3aa3440d0a75b6f5ed0cb 100644 (file)
@@ -6172,20 +6172,24 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
          if (slp_node)
            {
              /* Get vec defs for all the operands except the reduction index,
-               ensuring the ordering of the ops in the vector is kept.  */
+                ensuring the ordering of the ops in the vector is kept.  */
              auto_vec<tree, 3> slp_ops;
              auto_vec<vec<tree>, 3> vec_defs;
 
-             slp_ops.quick_push ((reduc_index == 0) ? NULL : ops[0]);
-             slp_ops.quick_push ((reduc_index == 1) ? NULL : ops[1]);
+             slp_ops.quick_push (reduc_index == 0 ? NULL : ops[0]);
+             slp_ops.quick_push (reduc_index == 1 ? NULL : ops[1]);
              if (op_type == ternary_op)
-               slp_ops.quick_push ((reduc_index == 2) ? NULL : ops[2]);
+               slp_ops.quick_push (reduc_index == 2 ? NULL : ops[2]);
 
              vect_get_slp_defs (slp_ops, slp_node, &vec_defs, -1);
 
-             vec_oprnds0.safe_splice (vec_defs[(reduc_index == 0) ? 1 : 0]);
+             vec_oprnds0.safe_splice (vec_defs[reduc_index == 0 ? 1 : 0]);
+             vec_defs[reduc_index == 0 ? 1 : 0].release ();
              if (op_type == ternary_op)
-               vec_oprnds1.safe_splice (vec_defs[(reduc_index == 2) ? 1 : 2]);
+               {
+                 vec_oprnds1.safe_splice (vec_defs[reduc_index == 2 ? 1 : 2]);
+                 vec_defs[reduc_index == 2 ? 1 : 2].release ();
+               }
            }
           else
            {
@@ -6194,7 +6198,7 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
               vec_oprnds0.quick_push (loop_vec_def0);
               if (op_type == ternary_op)
                {
-                op1 = (reduc_index == 0) ? ops[2] : ops[1];
+                op1 = reduc_index == 0 ? ops[2] : ops[1];
                  loop_vec_def1 = vect_get_vec_def_for_operand (op1, stmt);
                  vec_oprnds1.quick_push (loop_vec_def1);
                }