public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] copyprop_hardreg_forward needs to check HARD_REGNO_CALL_PART_CLOBBERED
@ 2014-05-07 15:52 Matthew Fortune
  2014-05-09  6:19 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Matthew Fortune @ 2014-05-07 15:52 UTC (permalink / raw)
  To: 'gcc-patches@gcc.gnu.org' (gcc-patches@gcc.gnu.org)
  Cc: Richard Sandiford, Rich Fuhler

[-- Attachment #1: Type: text/plain, Size: 865 bytes --]

The MIPS O32 FPXX ABI exposes a bug in regcprop where call part
clobbered information is not checked when calculating clobbered
registers. This is only one of many places that 
regs_invalidated_by_call is used without also checking 
HARD_REGNO_CALL_PART_CLOBBERED. This patch ensures that a part 
clobbered register is treated as if fully clobbered.

Other places where this same issue occurs are not so easily
fixed as they do not always have mode information available
when calculating clobbered registers. A solution to the larger
problem will be significantly more involved.

Exposed in a testcase as part of:
http://gcc.gnu.org/ml/gcc-patches/2014-05/msg00401.html

Regards,
Matthew

2014-05-07  Matthew Fortune  <matthew.fortune@imgtec.com>

gcc/
	* regcprop.c (copyprop_hardreg_forward_1): Account for
	HARD_REGNO_CALL_PART_CLOBBERED.

[-- Attachment #2: 0001-copyprop-part-clobbered.patch --]
[-- Type: application/octet-stream, Size: 1328 bytes --]

From 4849211c083e2ee6fc98ac4069983f9853724d04 Mon Sep 17 00:00:00 2001
From: mfortune <matthew.fortune@imgtec.com>
Date: Wed, 2 Apr 2014 21:55:05 +0100
Subject: [PATCH 2/2] Use part clobbered information when calculating clobbered regs

---
 gcc/regcprop.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/gcc/regcprop.c b/gcc/regcprop.c
index c1fbb65..fc42020 100644
--- a/gcc/regcprop.c
+++ b/gcc/regcprop.c
@@ -1011,7 +1011,6 @@ copyprop_hardreg_forward_1 (basic_block bb, struct value_data *vd)
 	  unsigned int set_nregs = 0;
 	  unsigned int regno;
 	  rtx exp;
-	  hard_reg_set_iterator hrsi;
 
 	  for (exp = CALL_INSN_FUNCTION_USAGE (insn); exp; exp = XEXP (exp, 1))
 	    {
@@ -1030,8 +1029,10 @@ copyprop_hardreg_forward_1 (basic_block bb, struct value_data *vd)
 		}
 	    }
 
-	  EXECUTE_IF_SET_IN_HARD_REG_SET (regs_invalidated_by_call, 0, regno, hrsi)
-	    if (regno < set_regno || regno >= set_regno + set_nregs)
+	  for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
+	    if ((TEST_HARD_REG_BIT (regs_invalidated_by_call, regno)
+		 || HARD_REGNO_CALL_PART_CLOBBERED (regno, vd->e[regno].mode))
+		&& (regno < set_regno || regno >= set_regno + set_nregs))
 	      kill_value_regno (regno, 1, vd);
 
 	  /* If SET was seen in CALL_INSN_FUNCTION_USAGE, and SET_SRC
-- 
1.7.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] copyprop_hardreg_forward needs to check HARD_REGNO_CALL_PART_CLOBBERED
  2014-05-07 15:52 [PATCH] copyprop_hardreg_forward needs to check HARD_REGNO_CALL_PART_CLOBBERED Matthew Fortune
@ 2014-05-09  6:19 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2014-05-09  6:19 UTC (permalink / raw)
  To: Matthew Fortune,
	'gcc-patches@gcc.gnu.org' (gcc-patches@gcc.gnu.org)
  Cc: Richard Sandiford, Rich Fuhler

On 05/07/14 09:52, Matthew Fortune wrote:
> The MIPS O32 FPXX ABI exposes a bug in regcprop where call part
> clobbered information is not checked when calculating clobbered
> registers. This is only one of many places that
> regs_invalidated_by_call is used without also checking
> HARD_REGNO_CALL_PART_CLOBBERED. This patch ensures that a part
> clobbered register is treated as if fully clobbered.
>
> Other places where this same issue occurs are not so easily
> fixed as they do not always have mode information available
> when calculating clobbered registers. A solution to the larger
> problem will be significantly more involved.
>
> Exposed in a testcase as part of:
> http://gcc.gnu.org/ml/gcc-patches/2014-05/msg00401.html
>
> Regards,
> Matthew
>
> 2014-05-07  Matthew Fortune  <matthew.fortune@imgtec.com>
>
> gcc/
> 	* regcprop.c (copyprop_hardreg_forward_1): Account for
> 	HARD_REGNO_CALL_PART_CLOBBERED.
OK.
Jeff

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-05-09  6:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-07 15:52 [PATCH] copyprop_hardreg_forward needs to check HARD_REGNO_CALL_PART_CLOBBERED Matthew Fortune
2014-05-09  6:19 ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).