diff mbox series

tree-optimization/109735 - conversion for vectorized pointer-diff

Message ID 20230505121843.AAF6813513@imap2.suse-dmz.suse.de
State New
Headers show
Series tree-optimization/109735 - conversion for vectorized pointer-diff | expand

Commit Message

Richard Biener May 5, 2023, 12:18 p.m. UTC
There's handling in vectorizable_operation for POINTER_DIFF_EXPR
requiring conversion of the result of the unsigned operation to
a signed type.  But that's conditional on the "default" kind of
vectorization.  In this PR it's shown the emulated vector path
needs it and I think the masked operation case will, too (though
we might eventually never mask an integral MINUS_EXPR).  So the
following makes that handling unconditional.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

	PR tree-optimization/109735
	* tree-vect-stmts.cc (vectorizable_operation): Perform
	conversion for POINTER_DIFF_EXPR unconditionally.
---
 gcc/tree-vect-stmts.cc | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index cf5194ea444..61a2da4ecee 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -6657,8 +6657,8 @@  vectorizable_operation (vec_info *vinfo,
 	  new_stmt = gimple_build_assign (NULL_TREE, VIEW_CONVERT_EXPR,
 					  build1 (VIEW_CONVERT_EXPR,
 						  vectype, result_low));
-	  result_low = make_ssa_name (vectype);
-	  gimple_assign_set_lhs (new_stmt, result_low);
+	  new_temp = make_ssa_name (vectype);
+	  gimple_assign_set_lhs (new_stmt, new_temp);
 	  vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi);
 	}
       else if (masked_loop_p && mask_out_inactive)
@@ -6734,18 +6734,19 @@  vectorizable_operation (vec_info *vinfo,
 	     AND it with a loop mask again.  */
 	  if (mask)
 	    loop_vinfo->vec_cond_masked_set.add ({ new_temp, mask });
+	}
 
-	  if (vec_cvt_dest)
-	    {
-	      new_temp = build1 (VIEW_CONVERT_EXPR, vectype_out, new_temp);
-	      new_stmt = gimple_build_assign (vec_cvt_dest, VIEW_CONVERT_EXPR,
-					      new_temp);
-	      new_temp = make_ssa_name (vec_cvt_dest, new_stmt);
-	      gimple_assign_set_lhs (new_stmt, new_temp);
-	      vect_finish_stmt_generation (vinfo, stmt_info,
-					   new_stmt, gsi);
-	    }
+      if (vec_cvt_dest)
+	{
+	  new_temp = build1 (VIEW_CONVERT_EXPR, vectype_out, new_temp);
+	  new_stmt = gimple_build_assign (vec_cvt_dest, VIEW_CONVERT_EXPR,
+					  new_temp);
+	  new_temp = make_ssa_name (vec_cvt_dest, new_stmt);
+	  gimple_assign_set_lhs (new_stmt, new_temp);
+	  vect_finish_stmt_generation (vinfo, stmt_info,
+				       new_stmt, gsi);
 	}
+
       if (slp_node)
 	SLP_TREE_VEC_STMTS (slp_node).quick_push (new_stmt);
       else