From b08c51086fceec9cd27858dae48bf55fbbfccc1c Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 17 Jul 2008 09:07:31 +0000 Subject: [PATCH] re PR middle-end/36753 (Forward propagation interacts badly with global register variable) gcc: 2008-07-17 Paolo Bonzini PR rtl-optimization/36753 * fwprop.c (use_killed_between): Don't shortcut single-definition global registers. gcc/testsuite: 2008-07-17 Paolo Bonzini PR rtl-optimization/36753 * gcc.target/i386/pr36753.c: New. From-SVN: r137913 --- gcc/ChangeLog | 6 ++++++ gcc/fwprop.c | 9 +++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/i386/pr36753.c | 31 +++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr36753.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 322e47d8399..7933b10d60c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-07-17 Paolo Bonzini + + PR rtl-optimization/36753 + * fwprop.c (use_killed_between): Don't shortcut + single-definition global registers. + 2008-07-16 Jan Hubicka * cgraph.h (varpool_empty_needed_queue): Declare. diff --git a/gcc/fwprop.c b/gcc/fwprop.c index e6700019644..fbe432974f4 100644 --- a/gcc/fwprop.c +++ b/gcc/fwprop.c @@ -527,10 +527,15 @@ use_killed_between (struct df_ref *use, rtx def_insn, rtx target_insn) return true; /* Check if the reg in USE has only one definition. We already - know that this definition reaches use, or we wouldn't be here. */ + know that this definition reaches use, or we wouldn't be here. + However, this is invalid for hard registers because if they are + live at the beginning of the function it does not mean that we + have an uninitialized access. */ regno = DF_REF_REGNO (use); def = DF_REG_DEF_CHAIN (regno); - if (def && (def->next_reg == NULL)) + if (def + && def->next_reg == NULL + && regno >= FIRST_PSEUDO_REGISTER) return false; /* Check locally if we are in the same basic block. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 54da1a1b18d..ec7dc0540d8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-07-17 Paolo Bonzini + + PR rtl-optimization/36753 + * gcc.target/i386/pr36753.c: New. + 2008-07-17 Tobias Burnus PR fortran/36825 diff --git a/gcc/testsuite/gcc.target/i386/pr36753.c b/gcc/testsuite/gcc.target/i386/pr36753.c new file mode 100644 index 00000000000..2d43d42a021 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr36753.c @@ -0,0 +1,31 @@ +/* { dg-options "-O2" } */ +/* { dg-do run } */ + +#if defined __i386__ +#define REG "edi" +#else +#define REG "r14" +#endif + +register unsigned long *ds asm(REG); + +extern void abort (void); + +__attribute__ ((noinline)) void +test (void) +{ + *++ds = 31337; +} + +int +main () +{ + unsigned long stack[2]; + stack[0] = 0; + stack[1] = 0; + ds = stack; + test (); + if (ds != stack + 1 || *ds != 31337) + abort (); + return 0; +} -- 2.11.4.GIT