https://gcc.gnu.org/g:f36ec88aa85a1a8f4ec300dfcd862fc4fbca1c53

commit r15-9590-gf36ec88aa85a1a8f4ec300dfcd862fc4fbca1c53
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Fri Apr 25 14:42:01 2025 +0200

    s390: Allow 5+ argument tail-calls in some -m31 -mzarch special cases 
[PR119873]
    
    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.
    
    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.
    
    (cherry picked from commit 3d156c9e9bdaf351f77e3348b7d0d75e08f65580)

Diff:
---
 gcc/config/s390/s390.cc                    | 13 ++++++++++++-
 gcc/testsuite/gcc.target/s390/pr119873-5.c | 11 +++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc
index 3cb2b5c1fa17..901e2613a762 100644
--- a/gcc/config/s390/s390.cc
+++ b/gcc/config/s390/s390.cc
@@ -14525,7 +14525,18 @@ s390_call_saved_register_used (tree call_expr)
              gcc_assert (REG_NREGS (r) == 1);
 
              if (!call_used_or_fixed_reg_p (REGNO (r)))
-               return true;
+               {
+                 rtx parm;
+                 if (CALL_EXPR_MUST_TAIL_CALL (call_expr)
+                     && 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;
+               }
            }
        }
     }
diff --git a/gcc/testsuite/gcc.target/s390/pr119873-5.c 
b/gcc/testsuite/gcc.target/s390/pr119873-5.c
new file mode 100644
index 000000000000..b5a7950d62b4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/pr119873-5.c
@@ -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);
+}

Reply via email to