https://gcc.gnu.org/g:3a8faf1e543f60c20d6a02ab815cdc83be94a14b

commit r16-6925-g3a8faf1e543f60c20d6a02ab815cdc83be94a14b
Author: Jakub Jelinek <[email protected]>
Date:   Tue Jan 20 15:38:24 2026 +0100

    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  <[email protected]>
    
            PR target/123724
            * config/aarch64/aarch64.cc (aarch64_possible_by_lane_insn_p): 
Ignore
            debug stmts.
    
            * g++.dg/opt/pr123724.C: New test.

Diff:
---
 gcc/config/aarch64/aarch64.cc       |  2 ++
 gcc/testsuite/g++.dg/opt/pr123724.C | 31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 3a453ad4918d..e443dce6644e 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 000000000000..9525e0f169ff
--- /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 <typename T> 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 <int> 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);
+    }
+}

Reply via email to