Add a utility function to check if a statement is lane-reducing operation,
which could simplify some existing code.
2024-06-16 Feng Xue <fxue@os.amperecomputing.com>
gcc/
* tree-vectorizer.h (lane_reducing_stmt_p): New function.
* tree-vect-slp.cc (vect_analyze_slp): Use new function
lane_reducing_stmt_p to check statement.
scalar_stmts.create (loop_vinfo->reductions.length ());
for (auto next_info : loop_vinfo->reductions)
{
- gassign *g;
next_info = vect_stmt_to_vectorize (next_info);
if ((STMT_VINFO_RELEVANT_P (next_info)
|| STMT_VINFO_LIVE_P (next_info))
{
/* Do not discover SLP reductions combining lane-reducing
ops, that will fail later. */
- if (!(g = dyn_cast <gassign *> (STMT_VINFO_STMT (next_info)))
- || !lane_reducing_op_p (gimple_assign_rhs_code (g)))
+ if (!lane_reducing_stmt_p (STMT_VINFO_STMT (next_info)))
scalar_stmts.quick_push (next_info);
else
{
&& th >= vect_vf_for_cost (loop_vinfo));
}
+/* Return true if CODE is a lane-reducing opcode. */
+
inline bool
lane_reducing_op_p (code_helper code)
{
return code == DOT_PROD_EXPR || code == WIDEN_SUM_EXPR || code == SAD_EXPR;
}
+/* Return true if STMT is a lane-reducing statement. */
+
+inline bool
+lane_reducing_stmt_p (gimple *stmt)
+{
+ if (auto *assign = dyn_cast <gassign *> (stmt))
+ return lane_reducing_op_p (gimple_assign_rhs_code (assign));
+ return false;
+}
+
/* Source location + hotness information. */
extern dump_user_location_t vect_location;