From: Jakub Jelinek Date: Tue, 20 Jan 2026 14:38:24 +0000 (+0100) Subject: aarch64: Ignore debug stmts in aarch64_possible_by_lane_insn_p [PR123724] X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a8faf1e543f60c20d6a02ab815cdc83be94a14b;p=thirdparty%2Fgcc.git aarch64: Ignore debug stmts in aarch64_possible_by_lane_insn_p [PR123724] Like in many other spots, when walking immediate uses for optimization decisions we should just ignore debug stmts. aarch64_possible_by_lane_insn_p wasn't ignoring those and wasted time on doing lookup for those and ICEd because it wasn't a vectorizable stmt. Fixed by ignoring debug stmts early during the immediate use walk. 2026-01-20 Jakub Jelinek PR target/123724 * config/aarch64/aarch64.cc (aarch64_possible_by_lane_insn_p): Ignore debug stmts. * g++.dg/opt/pr123724.C: New test. --- diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 3a453ad4918..e443dce6644 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -18536,6 +18536,8 @@ aarch64_possible_by_lane_insn_p (vec_info *m_vinfo, gimple *stmt) FOR_EACH_IMM_USE_FAST (use_p, iter, var) { gimple *new_stmt = USE_STMT (use_p); + if (is_gimple_debug (new_stmt)) + continue; auto stmt_info = vect_stmt_to_vectorize (m_vinfo->lookup_stmt (new_stmt)); auto rep_stmt = STMT_VINFO_STMT (stmt_info); /* Re-association is a problem here, since lane instructions are only diff --git a/gcc/testsuite/g++.dg/opt/pr123724.C b/gcc/testsuite/g++.dg/opt/pr123724.C new file mode 100644 index 00000000000..9525e0f169f --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr123724.C @@ -0,0 +1,31 @@ +// PR target/123724 +// { dg-do compile { target c++17 } } +// { dg-options "-O2 -g" } + +namespace std { +template struct initializer_list { + const T *_M_array; + decltype (sizeof 0) _M_len; + auto size () const { return _M_len; } + const T *begin () const { return _M_array; } + const T *end () const { return _M_array + _M_len; } +}; +} + +typedef std::initializer_list A; +struct B { + int b, c; + short d[4][3]; + void foo (int); + void bar (A x) { for (auto i : x) d[b][c] |= i; } +}; + +void +B::foo (int x) +{ + for (int i = 0; i < x; i++) + { + A x = { 1, 2 }; + bar (x); + } +}