]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aarch64: Ignore debug stmts in aarch64_possible_by_lane_insn_p [PR123724]
authorJakub Jelinek <jakub@redhat.com>
Tue, 20 Jan 2026 14:38:24 +0000 (15:38 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 20 Jan 2026 14:38:24 +0000 (15:38 +0100)
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.

gcc/config/aarch64/aarch64.cc
gcc/testsuite/g++.dg/opt/pr123724.C [new file with mode: 0644]

index 3a453ad4918d5e3d9f37e1937725e6cdd74f3af6..e443dce6644e09472ae15d18c59f8b4b7e304a8a 100644 (file)
@@ -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 (file)
index 0000000..9525e0f
--- /dev/null
@@ -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);
+    }
+}