From: Kewen Lin Date: Thu, 20 Oct 2022 09:07:05 +0000 (-0500) Subject: vect: Simplify first for shifted value generation [PR107240] X-Git-Tag: basepoints/gcc-14~3811 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d6e834ecf212e7fc6f585b154af224d2e38c749;p=thirdparty%2Fgcc.git vect: Simplify first for shifted value generation [PR107240] As PR107240 shows, when both the value to be shifted and the count used for shifting are constants, it can be simplified to one constant value, and doesn't actually require to check if the current target supports vector shift operations or not. This patch uses a canonical way proposed by Richi to generate the shifted value, if it can be simplified, the shift operation would be gone, otherwise it's the same as before. It can help to fix the failures of vect-bitfield-write-{2,3}.c on Power. PR tree-optimization/107240 2022-10-20 Richard Biener gcc/ChangeLog: * tree-vect-patterns.cc (vect_recog_bit_insert_pattern): Attempt to simplify shifted value first. --- diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index 6afd57a50c4b..d18e1e609969 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -2098,11 +2098,12 @@ vect_recog_bit_insert_pattern (vec_info *vinfo, stmt_vec_info stmt_info, tree shifted = value; if (shift_n) { - pattern_stmt - = gimple_build_assign (vect_recog_temp_ssa_var (container_type), - LSHIFT_EXPR, value, shift); - append_pattern_def_seq (vinfo, stmt_info, pattern_stmt); - shifted = gimple_get_lhs (pattern_stmt); + gimple_seq stmts = NULL; + shifted + = gimple_build (&stmts, LSHIFT_EXPR, container_type, value, shift); + if (!gimple_seq_empty_p (stmts)) + append_pattern_def_seq (vinfo, stmt_info, + gimple_seq_first_stmt (stmts)); } tree mask_t