public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <rsandifo@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: Scheduler patch for HARD_REGNO_CALL_PART_CLOBBERED
Date: Mon, 18 Nov 2002 03:16:00 -0000	[thread overview]
Message-ID: <wvnel9ji0vw.fsf@talisman.cambridge.redhat.com> (raw)

If an instruction modifies the clobbered part of a partly
call-clobbered register, the scheduler might still move
that instruction across a call.

Patch tested on sh64-elf.  Fixes the attached test case
for -m5-32media.  OK to install?

Richard


	* sched-deps.c (sched_analyze): Check HARD_REGNO_CALL_PART_CLOBBERED.

Index: sched-deps.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/sched-deps.c,v
retrieving revision 1.48
diff -c -d -p -F^[(a-zA-Z0-9_^#] -r1.48 sched-deps.c
*** sched-deps.c	27 Sep 2002 01:07:52 -0000	1.48
--- sched-deps.c	18 Nov 2002 11:10:25 -0000
*************** sched_analyze (deps, head, tail)
*** 1287,1294 ****
  		    SET_REGNO_REG_SET (reg_pending_sets, i);
  		    SET_REGNO_REG_SET (reg_pending_uses, i);
  		  }
! 		/* Other call-clobbered hard regs may be clobbered.  */
! 		else if (TEST_HARD_REG_BIT (regs_invalidated_by_call, i))
  		  SET_REGNO_REG_SET (reg_pending_clobbers, i);
  		/* We don't know what set of fixed registers might be used
  		   by the function, but it is certain that the stack pointer
--- 1287,1298 ----
  		    SET_REGNO_REG_SET (reg_pending_sets, i);
  		    SET_REGNO_REG_SET (reg_pending_uses, i);
  		  }
! 		/* Other call-clobbered hard regs may be clobbered.
! 		   Since we only have a choice between 'might be clobbered'
! 		   and 'definitely not clobbered', we must include all
! 		   partly call-clobbered registers here.  */
! 		else if (HARD_REGNO_CALL_PART_CLOBBERED (i, reg_raw_mode[i])
! 			 || TEST_HARD_REG_BIT (regs_invalidated_by_call, i))
  		  SET_REGNO_REG_SET (reg_pending_clobbers, i);
  		/* We don't know what set of fixed registers might be used
  		   by the function, but it is certain that the stack pointer
*** /dev/null	Tue Nov 14 21:44:43 2000
--- testsuite/gcc.c-torture/execute/20021112-5.c	Fri Nov 15 16:39:39 2002
***************
*** 0 ****
--- 1,26 ----
+ /* Test whether a partly call-clobbered register will be moved over a call.
+    Although the original test case didn't use any GNUisms, it proved
+    difficult to reduce without the named register extension.  */
+ #if __SH64__ == 32
+ #define LOC asm ("r10")
+ #else
+ #define LOC
+ #endif
+ 
+ unsigned int foo (char *c, unsigned int x, unsigned int y)
+ {
+   register unsigned int z LOC;
+ 
+   sprintf (c, "%d", x / y);
+   z = x + 1;
+   return z / (y + 1);
+ }
+ 
+ int main ()
+ {
+   char c[16];
+ 
+   if (foo (c, ~1U, 4) != (~0U / 5))
+     abort ();
+   exit (0);
+ }

             reply	other threads:[~2002-11-18 11:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-18  3:16 Richard Sandiford [this message]
2002-11-19 15:12 ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=wvnel9ji0vw.fsf@talisman.cambridge.redhat.com \
    --to=rsandifo@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).