aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@gcc.gnu.org>2015-06-03 12:59:38 +0000
committerNick Clifton <nickc@gcc.gnu.org>2015-06-03 12:59:38 +0000
commitfddde8d3d82bf11fa191d067dcf3ed505224089a (patch)
treee0bc4f4a51d0f86a089bcef35a324dd324abffef
parent9ce3eaa4fffc00adae2006fc59f8d1434496bb92 (diff)
downloadgcc-fddde8d3d82bf11fa191d067dcf3ed505224089a.zip
gcc-fddde8d3d82bf11fa191d067dcf3ed505224089a.tar.gz
gcc-fddde8d3d82bf11fa191d067dcf3ed505224089a.tar.bz2
rl78-real.md: Add peepholes to avoid a register copy when calling a function.
* config/rl78/rl78-real.md: Add peepholes to avoid a register copy when calling a function. * config/rl78/rl78.c (need_to_save): Do not push the frame pointer in an interrupt handler prologue if it is never used. From-SVN: r224076
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/config/rl78/rl78-real.md38
-rw-r--r--gcc/config/rl78/rl78.c6
3 files changed, 50 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b1b3dc6..cab2f38 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2015-06-03 Nick Clifton <nickc@redhat.com>
+
+ * config/rl78/rl78-real.md: Add peepholes to avoid a register
+ copy when calling a function.
+ * config/rl78/rl78.c (need_to_save): Do not push the frame
+ pointer in an interrupt handler prologue if it is never used.
+
2015-06-03 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
* ifcvt (end_ifcvt_sequence): Fix typo in comment above.
@@ -44,7 +51,7 @@
2015-06-03 Andrew Bennett <andrew.bennett@imgtec.com>
- * explow.c (plus_constant): Update check after force_const_mem call
+ * explow.c (plus_constant): Update check after force_const_mem call
to see if the value returned is not a NULL_RTX.
2015-06-03 Ilya Enkovich <ilya.enkovich@intel.com>
diff --git a/gcc/config/rl78/rl78-real.md b/gcc/config/rl78/rl78-real.md
index f6ab7ff..d6324e5 100644
--- a/gcc/config/rl78/rl78-real.md
+++ b/gcc/config/rl78/rl78-real.md
@@ -342,6 +342,25 @@
[(set (attr "update_Z") (const_string "clobber"))]
)
+;; Peephole to match:
+;;
+;; (set (reg1) (reg2))
+;; (call (mem (reg1)))
+;;
+;; and replace it with:
+;;
+;; (call (mem (reg2)))
+
+(define_peephole2
+ [(set (match_operand:HI 0 "register_operand") (match_operand:HI 1 "register_operand"))
+ (call (mem:HI (match_dup 0))(const_int 0))
+ ]
+ "peep2_regno_dead_p (2, REGNO (operands[0]))
+ && REGNO (operands[1]) < 8"
+ [(call (mem:HI (match_dup 1))(const_int 0))
+ ]
+)
+
(define_insn "*call_value_real"
[(set (match_operand 0 "register_operand" "=v,v")
(call (match_operand:HI 1 "memory_operand" "Wab,Wca")
@@ -353,6 +372,25 @@
[(set (attr "update_Z") (const_string "clobber"))]
)
+;; Peephole to match:
+;;
+;; (set (reg1) (reg2))
+;; (set (reg3) (call (mem (reg1))))
+;;
+;; and replace it with:
+;;
+;; (set (reg3) (call (mem (reg2))))
+
+(define_peephole2
+ [(set (match_operand:HI 0 "register_operand") (match_operand:HI 1 "register_operand"))
+ (set (match_operand:HI 2 "register_operand") (call (mem:HI (match_dup 0))(const_int 0)))
+ ]
+ "peep2_regno_dead_p (2, REGNO (operands[0]))
+ && REGNO (operands[1]) < 8"
+ [(set (match_dup 2) (call (mem:HI (match_dup 1))(const_int 0)))
+ ]
+)
+
(define_insn "*cbranchqi4_real_signed"
[(set (pc) (if_then_else
(match_operator 0 "rl78_cmp_operator_signed"
diff --git a/gcc/config/rl78/rl78.c b/gcc/config/rl78/rl78.c
index 6a15f91..c6a0d57 100644
--- a/gcc/config/rl78/rl78.c
+++ b/gcc/config/rl78/rl78.c
@@ -678,8 +678,10 @@ need_to_save (unsigned int regno)
/* If the handler is a non-leaf function then it may call
non-interrupt aware routines which will happily clobber
- any call_used registers, so we have to preserve them. */
- if (!crtl->is_leaf && call_used_regs[regno])
+ any call_used registers, so we have to preserve them.
+ We do not have to worry about the frame pointer register
+ though, as that is handled below. */
+ if (!crtl->is_leaf && call_used_regs[regno] && regno < 22)
return true;
/* Otherwise we only have to save a register, call_used