]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
vect: Use vect representative statement instead of original in patch recog [PR115060]
authorFeng Xue <fxue@os.amperecomputing.com>
Thu, 23 May 2024 07:25:53 +0000 (15:25 +0800)
committerFeng Xue <fxue@os.amperecomputing.com>
Tue, 28 May 2024 14:01:40 +0000 (22:01 +0800)
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 <fxue@os.amperecomputing.com>

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.

gcc/tree-vect-patterns.cc

index a313dc64643e8363349f9dcd6eed56bba1f87a71..8929e5aa7f3d02868b27f785531942315bf1ff63 100644 (file)
@@ -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 <gcall *> (STMT_VINFO_STMT (abd_pattern_vinfo));
   if (!abd_stmt
       || !gimple_call_internal_p (abd_stmt)