* [patch] PR51477
@ 2012-11-12 9:04 Steven Bosscher
2012-11-12 19:48 ` Richard Henderson
0 siblings, 1 reply; 2+ messages in thread
From: Steven Bosscher @ 2012-11-12 9:04 UTC (permalink / raw)
To: GCC Patches; +Cc: Jakub Jelinek
[-- 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;
+}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch] PR51477
2012-11-12 9:04 [patch] PR51477 Steven Bosscher
@ 2012-11-12 19:48 ` Richard Henderson
0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2012-11-12 19:48 UTC (permalink / raw)
To: Steven Bosscher; +Cc: GCC Patches, Jakub Jelinek
On 11/12/2012 01:04 AM, Steven Bosscher wrote:
> 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.
Ok.
r~
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-11-12 19:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-12 9:04 [patch] PR51477 Steven Bosscher
2012-11-12 19:48 ` Richard Henderson
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).