From: Feng Xue Date: Thu, 23 May 2024 07:25:53 +0000 (+0800) Subject: vect: Use vect representative statement instead of original in patch recog [PR115060] X-Git-Tag: basepoints/gcc-16~8690 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3aeff4ce95bd616a2108dc2363d9cbaba53b170;p=thirdparty%2Fgcc.git vect: Use vect representative statement instead of original in patch recog [PR115060] Some utility functions (such as vect_look_through_possible_promotion) that are to find out certain kind of direct or indirect definition SSA for a value, may return the original one of the SSA, not its pattern representative SSA, even pattern is involved. For example, a = (T1) patt_b; patt_b = (T2) c; // b = ... patt_c = not-a-cast; // c = ... Given 'a', the mentioned function will return 'c', instead of 'patt_c'. This subtlety would make some pattern recog code that is unaware of it mis-use the original instead of the new pattern statement, which is inconsistent wth processing logic of the pattern formation pass. This patch corrects the issue by forcing another utility function (vect_get_internal_def) return the pattern statement information to caller by default. 2024-05-23 Feng Xue gcc/ PR tree-optimization/115060 * tree-vect-patterns.cc (vect_get_internal_def): Return statement for vectorization. (vect_widened_op_tree): Call vect_get_internal_def instead of look_def to get statement information. (vect_recog_widen_abd_pattern): No need to call vect_stmt_to_vectorize. --- diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index a313dc64643..8929e5aa7f3 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -266,7 +266,7 @@ vect_get_internal_def (vec_info *vinfo, tree op) stmt_vec_info def_stmt_info = vinfo->lookup_def (op); if (def_stmt_info && STMT_VINFO_DEF_TYPE (def_stmt_info) == vect_internal_def) - return def_stmt_info; + return vect_stmt_to_vectorize (def_stmt_info); return NULL; } @@ -655,7 +655,8 @@ vect_widened_op_tree (vec_info *vinfo, stmt_vec_info stmt_info, tree_code code, /* Recursively process the definition of the operand. */ stmt_vec_info def_stmt_info - = vinfo->lookup_def (this_unprom->op); + = vect_get_internal_def (vinfo, this_unprom->op); + nops = vect_widened_op_tree (vinfo, def_stmt_info, code, widened_code, shift_p, max_nops, this_unprom, common_type, @@ -1739,7 +1740,6 @@ vect_recog_widen_abd_pattern (vec_info *vinfo, stmt_vec_info stmt_vinfo, if (!abd_pattern_vinfo) return NULL; - abd_pattern_vinfo = vect_stmt_to_vectorize (abd_pattern_vinfo); gcall *abd_stmt = dyn_cast (STMT_VINFO_STMT (abd_pattern_vinfo)); if (!abd_stmt || !gimple_call_internal_p (abd_stmt)