diff --git a/gcc/testsuite/gcc.target/aarch64/pr103523.c b/gcc/testsuite/gcc.target/aarch64/pr103523.c new file mode 100644 index 000000000000..736e8936c5f6 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr103523.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=armv8-a+sve -mtune=neoverse-v1 -Ofast" } */ + +void d(float *a, float b, int c) { + float e; + for (; c; c--, e += b) + a[c] = e; +} diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 7f544ba1fd51..f700d5e7ac2c 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -8065,6 +8065,15 @@ vectorizable_induction (loop_vec_info loop_vinfo, return false; } + step_expr = STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_info); + gcc_assert (step_expr != NULL_TREE); + tree step_vectype = get_same_sized_vectype (TREE_TYPE (step_expr), vectype); + + /* Check for backend support of PLUS/MINUS_EXPR. */ + if (!directly_supported_p (PLUS_EXPR, step_vectype) + || !directly_supported_p (MINUS_EXPR, step_vectype)) + return false; + if (!vec_stmt) /* transformation not required. */ { unsigned inside_cost = 0, prologue_cost = 0; @@ -8124,10 +8133,6 @@ vectorizable_induction (loop_vec_info loop_vinfo, if (dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, "transform induction phi.\n"); - step_expr = STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_info); - gcc_assert (step_expr != NULL_TREE); - tree step_vectype = get_same_sized_vectype (TREE_TYPE (step_expr), vectype); - pe = loop_preheader_edge (iv_loop); /* Find the first insertion point in the BB. */ basic_block bb = gimple_bb (phi);