]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
s390: Allow 5+ argument tail-calls in some -m31 -mzarch special cases [PR119873]
authorJakub Jelinek <jakub@redhat.com>
Fri, 25 Apr 2025 12:42:01 +0000 (14:42 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 25 Apr 2025 12:42:01 +0000 (14:42 +0200)
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  <jakub@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
gcc/testsuite/gcc.target/s390/pr119873-5.c [new file with mode: 0644]

index 0e9140ed5a0a43baf5b0b04a50f96e94905c0a6d..e3edf859513190c7da103bcbd0960a3f30b5b099 100644 (file)
@@ -14524,7 +14524,17 @@ 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 (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 (file)
index 0000000..b5a7950
--- /dev/null
@@ -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);
+}