[05/46] Fix make_ssa_name call in vectorizable_reduction

Message ID 87bmaxrmau.fsf@arm.com
State New
Headers show
Series
  • Remove vinfo_for_stmt etc.
Related show

Commit Message

Richard Sandiford July 24, 2018, 9:54 a.m.
The usual vectoriser dance to create new assignments is:

    new_stmt = gimple_build_assign (vec_dest, ...);
    new_temp = make_ssa_name (vec_dest, new_stmt);
    gimple_assign_set_lhs (new_stmt, new_temp);

but one site in vectorizable_reduction used:

    new_temp = make_ssa_name (vec_dest, new_stmt);

before creating new_stmt.

This method of creating statements probably needs cleaning up, but
that's for another day...


2018-07-24  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* tree-vect-loop.c (vectorizable_reduction): Fix an instance in
	which make_ssa_name was called with new_stmt before new_stmt
	had been created.

Comments

Richard Biener July 25, 2018, 8:46 a.m. | #1
On Tue, Jul 24, 2018 at 11:54 AM Richard Sandiford
<richard.sandiford@arm.com> wrote:
>

> The usual vectoriser dance to create new assignments is:

>

>     new_stmt = gimple_build_assign (vec_dest, ...);

>     new_temp = make_ssa_name (vec_dest, new_stmt);

>     gimple_assign_set_lhs (new_stmt, new_temp);

>

> but one site in vectorizable_reduction used:

>

>     new_temp = make_ssa_name (vec_dest, new_stmt);

>

> before creating new_stmt.

>

> This method of creating statements probably needs cleaning up, but

> that's for another day...


Yeah, one can elide the set_lhs by first allocating the SSA name
without defining stmt and then building the stmt with the SSA def
directly...

OK

>

> 2018-07-24  Richard Sandiford  <richard.sandiford@arm.com>

>

> gcc/

>         * tree-vect-loop.c (vectorizable_reduction): Fix an instance in

>         which make_ssa_name was called with new_stmt before new_stmt

>         had been created.

>

> Index: gcc/tree-vect-loop.c

> ===================================================================

> --- gcc/tree-vect-loop.c        2018-07-24 10:22:12.737465897 +0100

> +++ gcc/tree-vect-loop.c        2018-07-24 10:22:16.421433184 +0100

> @@ -7210,9 +7210,10 @@ vectorizable_reduction (gimple *stmt, gi

>               if (op_type == ternary_op)

>                 vop[2] = vec_oprnds2[i];

>

> -             new_temp = make_ssa_name (vec_dest, new_stmt);

> -             new_stmt = gimple_build_assign (new_temp, code,

> +             new_stmt = gimple_build_assign (vec_dest, code,

>                                               vop[0], vop[1], vop[2]);

> +             new_temp = make_ssa_name (vec_dest, new_stmt);

> +             gimple_assign_set_lhs (new_stmt, new_temp);

>             }

>           vect_finish_stmt_generation (stmt, new_stmt, gsi);

>

Patch

Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c	2018-07-24 10:22:12.737465897 +0100
+++ gcc/tree-vect-loop.c	2018-07-24 10:22:16.421433184 +0100
@@ -7210,9 +7210,10 @@  vectorizable_reduction (gimple *stmt, gi
 	      if (op_type == ternary_op)
 		vop[2] = vec_oprnds2[i];
 
-	      new_temp = make_ssa_name (vec_dest, new_stmt);
-	      new_stmt = gimple_build_assign (new_temp, code,
+	      new_stmt = gimple_build_assign (vec_dest, code,
 					      vop[0], vop[1], vop[2]);
+	      new_temp = make_ssa_name (vec_dest, new_stmt);
+	      gimple_assign_set_lhs (new_stmt, new_temp);
 	    }
 	  vect_finish_stmt_generation (stmt, new_stmt, gsi);