RE: [PATCH 1/2] Add vect_finish_stmt_generation for sequences
Richard Biener <[email protected]>
| Newsgroups | gmane.comp.gcc.patches |
|---|---|
| Message-ID | <[email protected]> |
On Fri, 14 Aug 2026, Tamar Christina wrote: > > -----Original Message----- > > From: Richard Biener <[email protected]> > > Sent: 14 August 2026 13:13 > > To: [email protected] > > Cc: Tamar Christina <[email protected]> > > Subject: [PATCH 1/2] Add vect_finish_stmt_generation for sequences > > > > The following attempts to make using gimple_build easier during > > vectorizer code generation by providing an overload of > > vect_finish_stmt_generation that handles a built sequence. > > In addition to inserting and finishing stmts on the sequence the > > ultimate result is made to be based on the passed vectorizer > > temporary (that gets us the fancy names). > > > > I have converted one instance in vectorizable_conversion which > > I'll need to handle both NOP_EXPR and VIEW_CONVERT_EXPR which > > gimple_build happily does correctly, but vect_gimple_build does > > not. > > > > Bootstrapped and tested on x86_64-unknown-linux-gnu. > > > > Does this look sensible? I can of course sepecial-case > > VIEW_CONVERT_EXPR manually as well. > > > > Yeah, it seems useful especially for cleaning up vectorizable_load/store > where we have a lot of additional addressing variables being emitted > all over the place. Or like emulated vectors - see below. I'm testing with that and will include it if successful. Richard. From 8f7242aa35b890c98814497059ad7907cc3b2fae Mon Sep 17 00:00:00 2001 From: Richard Biener <[email protected]> Date: Fri, 14 Aug 2026 15:14:08 +0200 Subject: [PATCH] amend To: [email protected] --- gcc/tree-vect-stmts.cc | 112 +++++++++++++---------------------------- 1 file changed, 34 insertions(+), 78 deletions(-) diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 070981dbdb3..e1d60a2c89b 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -6984,20 +6984,12 @@ vectorizable_operation (vec_info *vinfo, /* Lower the operation. This follows vector lowering. */ tree word_type = build_nonstandard_integer_type (GET_MODE_BITSIZE (vec_mode).to_constant (), 1); - tree wvop0 = make_ssa_name (word_type); - new_stmt = gimple_build_assign (wvop0, VIEW_CONVERT_EXPR, - build1 (VIEW_CONVERT_EXPR, - word_type, vop0)); - vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); + gimple_seq stmts = NULL; + tree wvop0 = gimple_build (&stmts, + VIEW_CONVERT_EXPR, word_type, vop0); tree wvop1 = NULL_TREE; if (vop1) - { - wvop1 = make_ssa_name (word_type); - new_stmt = gimple_build_assign (wvop1, VIEW_CONVERT_EXPR, - build1 (VIEW_CONVERT_EXPR, - word_type, vop1)); - vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); - } + wvop1 = gimple_build (&stmts, VIEW_CONVERT_EXPR, word_type, vop1); tree result_low; if (code == PLUS_EXPR || code == MINUS_EXPR || code == NEGATE_EXPR) @@ -7013,80 +7005,44 @@ vectorizable_operation (vec_info *vinfo, tree signs; if (code == PLUS_EXPR || code == MINUS_EXPR) { - signs = make_ssa_name (word_type); - new_stmt = gimple_build_assign (signs, - BIT_XOR_EXPR, wvop0, wvop1); - vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); - tree b_low = make_ssa_name (word_type); - new_stmt = gimple_build_assign (b_low, BIT_AND_EXPR, - wvop1, low_bits); - vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); - tree a_low = make_ssa_name (word_type); + signs = gimple_build (&stmts, BIT_XOR_EXPR, + word_type, wvop0, wvop1); + tree b_low = gimple_build (&stmts, BIT_AND_EXPR, + word_type, wvop1, low_bits); + tree a_low; if (code == PLUS_EXPR) - new_stmt = gimple_build_assign (a_low, BIT_AND_EXPR, - wvop0, low_bits); + a_low = gimple_build (&stmts, BIT_AND_EXPR, + word_type, wvop0, low_bits); else - new_stmt = gimple_build_assign (a_low, BIT_IOR_EXPR, - wvop0, high_bits); - vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); + a_low = gimple_build (&stmts, BIT_IOR_EXPR, + word_type, wvop0, high_bits); if (code == MINUS_EXPR) - { - new_stmt = gimple_build_assign (NULL_TREE, - BIT_NOT_EXPR, signs); - signs = make_ssa_name (word_type); - gimple_assign_set_lhs (new_stmt, signs); - vect_finish_stmt_generation (vinfo, stmt_info, - new_stmt, gsi); - } - new_stmt = gimple_build_assign (NULL_TREE, BIT_AND_EXPR, - signs, high_bits); - signs = make_ssa_name (word_type); - gimple_assign_set_lhs (new_stmt, signs); - vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); - result_low = make_ssa_name (word_type); - new_stmt = gimple_build_assign (result_low, code, - a_low, b_low); - vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); + signs = gimple_build (&stmts, BIT_NOT_EXPR, + word_type, signs); + signs = gimple_build (&stmts, BIT_AND_EXPR, + word_type, signs, high_bits); + result_low = gimple_build (&stmts, code, + word_type, a_low, b_low); } else /* if (code == NEGATE_EXPR) */ { - tree a_low = make_ssa_name (word_type); - new_stmt = gimple_build_assign (a_low, BIT_AND_EXPR, - wvop0, low_bits); - vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); - signs = make_ssa_name (word_type); - new_stmt = gimple_build_assign (signs, BIT_NOT_EXPR, wvop0); - vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); - new_stmt = gimple_build_assign (NULL_TREE, BIT_AND_EXPR, - signs, high_bits); - signs = make_ssa_name (word_type); - gimple_assign_set_lhs (new_stmt, signs); - vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); - result_low = make_ssa_name (word_type); - new_stmt = gimple_build_assign (result_low, - MINUS_EXPR, high_bits, a_low); - vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); + tree a_low = gimple_build (&stmts, BIT_AND_EXPR, + word_type, wvop0, low_bits); + signs = gimple_build (&stmts, BIT_NOT_EXPR, + word_type, wvop0); + signs = gimple_build (&stmts, BIT_AND_EXPR, + word_type, signs, high_bits); + result_low = gimple_build (&stmts, MINUS_EXPR, + word_type, high_bits, a_low); } - new_stmt = gimple_build_assign (NULL_TREE, BIT_XOR_EXPR, - result_low, signs); - result_low = make_ssa_name (word_type); - gimple_assign_set_lhs (new_stmt, result_low); - vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); + result_low = gimple_build (&stmts, BIT_XOR_EXPR, + word_type, result_low, signs); } else - { - new_stmt = gimple_build_assign (NULL_TREE, code, wvop0, wvop1); - result_low = make_ssa_name (word_type); - gimple_assign_set_lhs (new_stmt, result_low); - vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); - - } - new_stmt = gimple_build_assign (NULL_TREE, VIEW_CONVERT_EXPR, - build1 (VIEW_CONVERT_EXPR, - vectype, 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); + result_low = gimple_build (&stmts, code, word_type, wvop0, wvop1); + new_temp = gimple_build (&stmts, VIEW_CONVERT_EXPR, + vectype, result_low); + vect_finish_stmt_generation (vinfo, stmt_info, stmts, vec_dest, gsi); } else if ((masked_loop_p || len_loop_p) && mask_out_inactive) { @@ -7190,7 +7146,7 @@ vectorizable_operation (vec_info *vinfo, new_stmt, gsi); } - slp_node->push_vec_def (new_stmt); + slp_node->push_vec_def (new_temp); } vec_oprnds0.release (); -- 2.51.0