Hi!

Here is a patch to handle the PARALLEL case too.
I think we can just use rtx_equal_p there, because it will always use
SImode in the EXPR_LIST REGs in that case.

Bootstrapped/regtested on s390x-linux, ok for trunk and 15.2 (with
CALL_EXPR_MUST_TAIL_CALL (call_expr) && added in that case)?

2025-04-25  Jakub Jelinek  <ja...@redhat.com>

        PR target/119873
        * config/s390/s390.cc (s390_call_saved_register_used): Don't return
        true if default definition of PARM_DECL SSA_NAME of the same register
        is passed in call saved register in the PARALLEL case either.

        * gcc.target/s390/pr119873-5.c: New test.

--- gcc/config/s390/s390.cc.jj  2025-04-24 20:04:23.252274117 +0200
+++ gcc/config/s390/s390.cc     2025-04-24 20:18:44.832835186 +0200
@@ -14524,7 +14524,17 @@ s390_call_saved_register_used (tree call
              gcc_assert (REG_NREGS (r) == 1);
 
              if (!call_used_or_fixed_reg_p (REGNO (r)))
-               return true;
+               {
+                 rtx parm;
+                 if (TREE_CODE (parameter) == SSA_NAME
+                     && SSA_NAME_IS_DEFAULT_DEF (parameter)
+                     && SSA_NAME_VAR (parameter)
+                     && TREE_CODE (SSA_NAME_VAR (parameter)) == PARM_DECL
+                     && (parm = DECL_INCOMING_RTL (SSA_NAME_VAR (parameter)))
+                     && rtx_equal_p (parm_rtx, parm))
+                   break;
+                 return true;
+               }
            }
        }
     }
--- gcc/testsuite/gcc.target/s390/pr119873-5.c.jj       2025-04-24 
20:23:36.469962609 +0200
+++ gcc/testsuite/gcc.target/s390/pr119873-5.c  2025-04-24 20:24:03.078609253 
+0200
@@ -0,0 +1,11 @@
+/* PR target/119873 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -m31 -mzarch" } */
+
+extern void foo (int x, int y, int z, long long w, int v);
+
+void
+bar (int x, int y, int z, long long w, int v)
+{
+  [[gnu::musttail]] return foo (x, y, z, w, v);
+}

        Jakub

Reply via email to