From 37b5f031292fbdb854ee791de3883362cf2afcff Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 5 May 2023 08:54:28 +0200 Subject: [PATCH] tree-optimization/109735 - conversion for vectorized pointer-diff 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. 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 --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index cf5194ea4440..61a2da4ecee9 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 -- 2.43.5