From: Richard Biener Date: Mon, 27 Oct 2025 10:31:32 +0000 (+0100) Subject: tree-optimization/122419 - reduction chain with conversion as op X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=187bccedfc454304f7e35697baa5337c59fa2a58;p=thirdparty%2Fgcc.git tree-optimization/122419 - reduction chain with conversion as op The following deals with reduction detection handling a non-noop conversion as reduction operation and makes the reduction chain chain re-discovery handle this situation the same. PR tree-optimization/122419 * tree-vect-slp.cc (vect_analyze_slp_reduc_chain): Only skip noop conversions. * gcc.dg/vect/pr122419.c: New testcase. --- diff --git a/gcc/testsuite/gcc.dg/vect/pr122419.c b/gcc/testsuite/gcc.dg/vect/pr122419.c new file mode 100644 index 00000000000..b428cfb1812 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr122419.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +int a; +long b; +void c() +{ + for (; b; b--) + a = (char)a; +} diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 31d84857d49..e02b3379bb4 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -4217,6 +4217,7 @@ vect_analyze_slp_reduc_chain (loop_vec_info vinfo, if (!gimple_extract_op (STMT_VINFO_STMT (vect_orig_stmt (stmt)), &op)) gcc_unreachable (); if (CONVERT_EXPR_CODE_P (op.code) + && tree_nop_conversion_p (op.type, TREE_TYPE (op.ops[0])) && (first || is_a (STMT_VINFO_STMT (next_stmt)))) ;