]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[ARM] Enable tail call optimization for long call
authorJiong Wang <jiong.wang@arm.com>
Fri, 25 Apr 2014 17:00:33 +0000 (17:00 +0000)
committerYufeng Zhang <yufeng@gcc.gnu.org>
Fri, 25 Apr 2014 17:00:33 +0000 (17:00 +0000)
gcc/

* config/arm/predicates.md (call_insn_operand): Add long_call check.
* config/arm/arm.md (sibcall, sibcall_value): Force the address to
reg for long_call.
* config/arm/arm.c (arm_function_ok_for_sibcall): Remove long_call
restriction.

gcc/testsuite

* gcc.target/arm/tail-long-call.c: New test.

From-SVN: r209808

gcc/ChangeLog
gcc/config/arm/arm.c
gcc/config/arm/arm.md
gcc/config/arm/predicates.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arm/tail-long-call.c [new file with mode: 0644]

index d08a41754a9098619f676e269f7cefeaef0b9556..7de7be5d305ba555d9faf7463ffa48e89df1349d 100644 (file)
@@ -1,3 +1,11 @@
+2014-04-25  Jiong Wang  <jiong.wang@arm.com>
+
+       * config/arm/predicates.md (call_insn_operand): Add long_call check.
+       * config/arm/arm.md (sibcall, sibcall_value): Force the address to
+       reg for long_call.
+       * config/arm/arm.c (arm_function_ok_for_sibcall): Remove long_call
+       restriction.
+
 2014-04-25  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * config/arm/arm.c (arm_cortex_a8_tune): Initialise
index de457a36647c83d7752602798df69baca53e865d..16fc7edd96c2595fb0e2dc152bafd5d614bc5277 100644 (file)
@@ -6217,11 +6217,6 @@ arm_function_ok_for_sibcall (tree decl, tree exp)
   if (TARGET_VXWORKS_RTP && flag_pic && !targetm.binds_local_p (decl))
     return false;
 
-  /* Cannot tail-call to long calls, since these are out of range of
-     a branch instruction.  */
-  if (decl && arm_is_long_call_p (decl))
-    return false;
-
   /* If we are interworking and the function is not declared static
      then we can't tail-call it unless we know that it exists in this
      compilation unit (since it might be a Thumb routine).  */
index 8a949b929fa01eeadc3405e1830617f579bba57c..97753ce1e9846b6d760b87cfa3aa52a8a79364fe 100644 (file)
   "TARGET_32BIT"
   "
   {
-    if (!REG_P (XEXP (operands[0], 0))
-       && (GET_CODE (XEXP (operands[0], 0)) != SYMBOL_REF))
+    if ((!REG_P (XEXP (operands[0], 0))
+        && GET_CODE (XEXP (operands[0], 0)) != SYMBOL_REF)
+       || (GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
+           && arm_is_long_call_p (SYMBOL_REF_DECL (XEXP (operands[0], 0)))))
      XEXP (operands[0], 0) = force_reg (SImode, XEXP (operands[0], 0));
 
     if (operands[2] == NULL_RTX)
   "TARGET_32BIT"
   "
   {
-    if (!REG_P (XEXP (operands[1], 0)) &&
-       (GET_CODE (XEXP (operands[1],0)) != SYMBOL_REF))
+    if ((!REG_P (XEXP (operands[1], 0))
+        && GET_CODE (XEXP (operands[1], 0)) != SYMBOL_REF)
+       || (GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
+           && arm_is_long_call_p (SYMBOL_REF_DECL (XEXP (operands[1], 0)))))
      XEXP (operands[1], 0) = force_reg (SImode, XEXP (operands[1], 0));
 
     if (operands[3] == NULL_RTX)
index 6273e8820c6b71c1b5846125b2e265f89a66ce2d..d74fcb31bc7667ce549e4380a68237ce107c3558 100644 (file)
        (match_code "reg" "0")))
 
 (define_predicate "call_insn_operand"
-  (ior (match_code "symbol_ref")
+  (ior (and (match_code "symbol_ref")
+           (match_test "!arm_is_long_call_p (SYMBOL_REF_DECL (op))"))
        (match_operand 0 "s_register_operand")))
index 0d65bef0ad09596f3328cd54d830a30209535aaa..88681c8d698f3f160c90bb41dfd2bea67b259193 100644 (file)
@@ -1,3 +1,7 @@
+2014-04-25  Jiong Wang  <jiong.wang@arm.com>
+
+       * gcc.target/arm/tail-long-call.c: New test.
+
 2014-04-25  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
        PR tree-optimization/60930
diff --git a/gcc/testsuite/gcc.target/arm/tail-long-call.c b/gcc/testsuite/gcc.target/arm/tail-long-call.c
new file mode 100644 (file)
index 0000000..9b27468
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-skip-if "need at least armv5te" { *-*-* } { "-march=armv[234]*" "-mthumb" } { "" } } */
+/* { dg-options "-O2 -march=armv5te -marm" } */
+/* { dg-final { scan-assembler "bx" } } */
+/* { dg-final { scan-assembler-not "blx" } } */
+
+int lcal (int) __attribute__ ((long_call));
+
+int
+dec (int a)
+{
+  return lcal (a);
+}