commit g:1786be14e94bf1a7806b9dc09186f021737f0227 stops storing in STMT_VINFO_VECTYPE the vectype of the current stmt being vectorized and instead requires the use of SLP_TREE_VECTYPE for everything but data-refs.
This means that STMT_VINFO_VECTYPE (stmt_info) will always be NULL and so aarch64_bool_compound_p will never properly cost predicate AND operations anymore resulting in less vectorization. This patch changes it to use SLP_TREE_VECTYPE and pass the slp_node to aarch64_bool_compound_p. Bootstrapped Regtested on aarch64-none-linux-gnu, arm-none-linux-gnueabihf, x86_64-pc-linux-gnu -m32, -m64 and no issues and fixes a couple more sve tests. Ok for master? Thanks, Tamar gcc/ChangeLog: PR target/121536 * config/aarch64/aarch64.cc (aarch64_bool_compound_p): Use SLP_TREE_VECTYPE instead of STMT_VINFO_VECTYPE. (aarch64_adjust_stmt_cost, aarch64_vector_costs::count_ops): Pass SLP node to aarch64_bool_compound_p. gcc/testsuite/ChangeLog: PR target/121536 * g++.target/aarch64/sve/pr121536.cc: New test. --- diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 2971224566f14da4a163a7d0aed72bdbb3ac40f9..489bffce4d0b733b2d003c1f156a36ea26de456f 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -17378,13 +17378,14 @@ aarch64_multiply_add_p (vec_info *vinfo, stmt_vec_info stmt_info, static bool aarch64_bool_compound_p (vec_info *vinfo, stmt_vec_info stmt_info, - unsigned int vec_flags) + slp_tree node, unsigned int vec_flags) { gassign *assign = dyn_cast<gassign *> (stmt_info->stmt); if (!assign + || !node || gimple_assign_rhs_code (assign) != BIT_AND_EXPR - || !STMT_VINFO_VECTYPE (stmt_info) - || !VECTOR_BOOLEAN_TYPE_P (STMT_VINFO_VECTYPE (stmt_info))) + || !SLP_TREE_VECTYPE (node) + || !VECTOR_BOOLEAN_TYPE_P (SLP_TREE_VECTYPE (node))) return false; for (int i = 1; i < 3; ++i) @@ -17723,7 +17724,7 @@ aarch64_adjust_stmt_cost (vec_info *vinfo, vect_cost_for_stmt kind, /* For vector boolean ANDs with a compare operand we just need one insn. */ - if (aarch64_bool_compound_p (vinfo, stmt_info, vec_flags)) + if (aarch64_bool_compound_p (vinfo, stmt_info, node, vec_flags)) return 0; } @@ -17804,7 +17805,7 @@ aarch64_vector_costs::count_ops (unsigned int count, vect_cost_for_stmt kind, /* Assume that bool AND with compare operands will become a single operation. */ - if (aarch64_bool_compound_p (m_vinfo, stmt_info, m_vec_flags)) + if (aarch64_bool_compound_p (m_vinfo, stmt_info, node, m_vec_flags)) return; } diff --git a/gcc/testsuite/g++.target/aarch64/sve/pr121536.cc b/gcc/testsuite/g++.target/aarch64/sve/pr121536.cc new file mode 100644 index 0000000000000000000000000000000000000000..bd3c69b3801b2e7829ca55c8ed6e76ff288cf2a2 --- /dev/null +++ b/gcc/testsuite/g++.target/aarch64/sve/pr121536.cc @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-vect-all -std=c++14 -O3 -mcpu=neoverse-v2 -msve-vector-bits=128" } */ + +using a = long; +using b = a; +using c = double; +b d; +c e; +void f() { + for (b g; g < d; ++g) + e += g; +} + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ --
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 2971224566f14da4a163a7d0aed72bdbb3ac40f9..489bffce4d0b733b2d003c1f156a36ea26de456f 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -17378,13 +17378,14 @@ aarch64_multiply_add_p (vec_info *vinfo, stmt_vec_info stmt_info, static bool aarch64_bool_compound_p (vec_info *vinfo, stmt_vec_info stmt_info, - unsigned int vec_flags) + slp_tree node, unsigned int vec_flags) { gassign *assign = dyn_cast<gassign *> (stmt_info->stmt); if (!assign + || !node || gimple_assign_rhs_code (assign) != BIT_AND_EXPR - || !STMT_VINFO_VECTYPE (stmt_info) - || !VECTOR_BOOLEAN_TYPE_P (STMT_VINFO_VECTYPE (stmt_info))) + || !SLP_TREE_VECTYPE (node) + || !VECTOR_BOOLEAN_TYPE_P (SLP_TREE_VECTYPE (node))) return false; for (int i = 1; i < 3; ++i) @@ -17723,7 +17724,7 @@ aarch64_adjust_stmt_cost (vec_info *vinfo, vect_cost_for_stmt kind, /* For vector boolean ANDs with a compare operand we just need one insn. */ - if (aarch64_bool_compound_p (vinfo, stmt_info, vec_flags)) + if (aarch64_bool_compound_p (vinfo, stmt_info, node, vec_flags)) return 0; } @@ -17804,7 +17805,7 @@ aarch64_vector_costs::count_ops (unsigned int count, vect_cost_for_stmt kind, /* Assume that bool AND with compare operands will become a single operation. */ - if (aarch64_bool_compound_p (m_vinfo, stmt_info, m_vec_flags)) + if (aarch64_bool_compound_p (m_vinfo, stmt_info, node, m_vec_flags)) return; } diff --git a/gcc/testsuite/g++.target/aarch64/sve/pr121536.cc b/gcc/testsuite/g++.target/aarch64/sve/pr121536.cc new file mode 100644 index 0000000000000000000000000000000000000000..bd3c69b3801b2e7829ca55c8ed6e76ff288cf2a2 --- /dev/null +++ b/gcc/testsuite/g++.target/aarch64/sve/pr121536.cc @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-vect-all -std=c++14 -O3 -mcpu=neoverse-v2 -msve-vector-bits=128" } */ + +using a = long; +using b = a; +using c = double; +b d; +c e; +void f() { + for (b g; g < d; ++g) + e += g; +} + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */