https://gcc.gnu.org/g:a1e616955e9971fda54a160a49e6cf70dd838a0c

commit r16-2182-ga1e616955e9971fda54a160a49e6cf70dd838a0c
Author: Richard Sandiford <richard.sandif...@arm.com>
Date:   Thu Jul 10 22:00:41 2025 +0100

    aarch64: Guard VF-based costing with !m_costing_for_scalar
    
    g:4b47acfe2b626d1276e229a0cf165e934813df6c caused a segfault
    in aarch64_vector_costs::analyze_loop_vinfo when costing scalar
    code, since we'd end up dividing by a zero VF.
    
    Much of the structure of the aarch64 costing code dates from
    a stage 4 patch, when we had to work within the bounds of what
    the target-independent code did.  Some of it could do with a
    rework now that we're not so constrained.
    
    This patch is therefore an emergency fix rather than the best
    long-term solution.  I'll revisit when I have more time to think
    about it.
    
    gcc/
            * config/aarch64/aarch64.cc (aarch64_vector_costs::add_stmt_cost):
            Guard VF-based costing with !m_costing_for_scalar.

Diff:
---
 gcc/config/aarch64/aarch64.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 27c315fc35e8..10b8ed5d3874 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -17932,7 +17932,7 @@ aarch64_vector_costs::add_stmt_cost (int count, 
vect_cost_for_stmt kind,
 
   /* Do one-time initialization based on the vinfo.  */
   loop_vec_info loop_vinfo = dyn_cast<loop_vec_info> (m_vinfo);
-  if (!m_analyzed_vinfo)
+  if (!m_analyzed_vinfo && !m_costing_for_scalar)
     {
       if (loop_vinfo)
        analyze_loop_vinfo (loop_vinfo);

Reply via email to