From: Steven Bosscher <stevenb.gcc@gmail.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Jakub Jelinek <jakub@redhat.com>
Subject: [patch] PR51477
Date: Mon, 12 Nov 2012 09:04:00 -0000 [thread overview]
Message-ID: <CABu31nM8h+fEzcouFu4+o3ML7bVwqD4XZYSs4DOzdY5h9=+Fng@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 792 bytes --]
Hello,
In this PR, a set to a global reg is removed by fast-dce and ud-dce.
Such sets should always be preserved.
The proposed fix is to make global regs always live. This is done in
the df-* parts of the patch from Jakub (the test case is also his).
In addition, ud-dce should consider sets of global regs inherently
necessary for DCE.
Bootstrapped and tested on x86_64-unknown-linux-gnu. OK for trunk?
Ciao!
Steven
gcc/
PR rtl-optimization/51447
* df-scan.c (df_get_entry_block_def_set): Add global regs to the set.
* df-problems.c (df_lr_local_compute): Make global regs always live.
PR rtl-optimization/51447
* dce.c (deletable_insn_p): Make insns setting a global reg
inherently necessary.
testsuite/
PR rtl-optimization/51447
* gcc.c-torture/execute/pr51447.c: New test.
[-- Attachment #2: PR51447.diff --]
[-- Type: application/octet-stream, Size: 3205 bytes --]
gcc/
PR rtl-optimization/51447
* df-scan.c (df_get_entry_block_def_set): Add global regs to the set.
* df-problems.c (df_lr_local_compute): Make global regs always live.
* dce.c (deletable_insn_p): Make insns setting a global reg
inherently necessary.
testsuite/
PR rtl-optimization/51447
* gcc.c-torture/execute/pr51447.c: New test.
Index: df-scan.c
===================================================================
--- df-scan.c (revision 193411)
+++ df-scan.c (working copy)
@@ -3790,8 +3790,12 @@ df_get_entry_block_def_set (bitmap entry
bitmap_clear (entry_block_defs);
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
- if (FUNCTION_ARG_REGNO_P (i))
- bitmap_set_bit (entry_block_defs, INCOMING_REGNO (i));
+ {
+ if (global_regs[i])
+ bitmap_set_bit (entry_block_defs, i);
+ if (FUNCTION_ARG_REGNO_P (i))
+ bitmap_set_bit (entry_block_defs, INCOMING_REGNO (i));
+ }
/* The always important stack pointer. */
bitmap_set_bit (entry_block_defs, STACK_POINTER_REGNUM);
Index: df-problems.c
===================================================================
--- df-problems.c (revision 193411)
+++ df-problems.c (working copy)
@@ -931,7 +931,7 @@ df_lr_bb_local_compute (unsigned int bb_
static void
df_lr_local_compute (bitmap all_blocks ATTRIBUTE_UNUSED)
{
- unsigned int bb_index;
+ unsigned int bb_index, i;
bitmap_iterator bi;
bitmap_clear (&df->hardware_regs_used);
@@ -939,6 +939,11 @@ df_lr_local_compute (bitmap all_blocks A
/* The all-important stack pointer must always be live. */
bitmap_set_bit (&df->hardware_regs_used, STACK_POINTER_REGNUM);
+ /* Global regs are always live, too. */
+ for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
+ if (global_regs[i])
+ bitmap_set_bit (&df->hardware_regs_used, i);
+
/* Before reload, there are a few registers that must be forced
live everywhere -- which might not already be the case for
blocks within infinite loops. */
Index: dce.c
===================================================================
--- dce.c (revision 193411)
+++ dce.c (working copy)
@@ -121,6 +121,12 @@ deletable_insn_p (rtx insn, bool fast, b
&& !insn_nothrow_p (insn))
return false;
+ /* If INSN sets a global_reg, leave it untouched. */
+ for (df_ref *def_rec = DF_INSN_DEFS (insn); *def_rec; def_rec++)
+ if (HARD_REGISTER_NUM_P (DF_REF_REGNO (*def_rec))
+ && global_regs[DF_REF_REGNO (*def_rec)])
+ return false;
+
body = PATTERN (insn);
switch (GET_CODE (body))
{
Index: testsuite/gcc.c-torture/execute/pr51447.c
===================================================================
--- testsuite/gcc.c-torture/execute/pr51447.c (revision 0)
+++ testsuite/gcc.c-torture/execute/pr51447.c (revision 0)
@@ -0,0 +1,27 @@
+/* PR rtl-optimization/51447 */
+
+extern void abort (void);
+
+#ifdef __x86_64__
+register void *ptr asm ("rbx");
+#else
+void *ptr;
+#endif
+
+int
+main (void)
+{
+ __label__ nonlocal_lab;
+ __attribute__((noinline, noclone)) void
+ bar (void *func)
+ {
+ ptr = func;
+ goto nonlocal_lab;
+ }
+ bar (&&nonlocal_lab);
+ return 1;
+nonlocal_lab:
+ if (ptr != &&nonlocal_lab)
+ abort ();
+ return 0;
+}
next reply other threads:[~2012-11-12 9:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-12 9:04 Steven Bosscher [this message]
2012-11-12 19:48 ` 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='CABu31nM8h+fEzcouFu4+o3ML7bVwqD4XZYSs4DOzdY5h9=+Fng@mail.gmail.com' \
--to=stevenb.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
/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).