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 <jakub@redhat.com>
PR target/123724
* config/aarch64/aarch64.cc (aarch64_possible_by_lane_insn_p): Ignore
debug stmts.
* g++.dg/opt/pr123724.C: New test.
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
--- /dev/null
+// 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);
+ }
+}