From 46e3b90f7e326c672c4ecddf5287f603a89d03ef Mon Sep 17 00:00:00 2001 From: Mark Shinwell Date: Mon, 8 Jan 2007 08:33:42 +0000 Subject: [PATCH] re PR tree-optimization/29877 (out of SSA (TER) extends variable life of variable beyond original declared) PR tree-optimization/29877 gcc/ * tree-ssa-ter.c (is_replaceable_p): Deem assignments with a register variable on the RHS to not be replaceable. gcc/testsuite/ * gcc.dg/pr16194.c: Skip test entirely if we don't know the name of a hard register for the target concerned. Adjust dg-error directives to cope with new behaviour of TER. From-SVN: r120571 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/gcc.dg/pr16194.c | 31 ++++++++++++++++++++----------- gcc/tree-ssa-ter.c | 6 ++++++ 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8e36d9189b2..371f1056539 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2007-01-08 Mark Shinwell + + PR tree-optimization/29877 + * tree-ssa-ter.c (is_replaceable_p): Deem assignments with + a register variable on the RHS to not be replaceable. + 2007-01-08 Chen Liqin * config/score/t-score-elf (MULTILIB_OPTIONS): Change. * config/score/predicates.md (const_uimm5, sr0_operand, const_simm12, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a42328a5907..47dce00a908 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2007-01-08 Mark Shinwell + + PR tree-optimization/29877 + * gcc.dg/pr16194.c: Skip test entirely if we don't know the + name of a hard register for the target concerned. Adjust dg-error + directives to cope with new behaviour of TER. + 2007-01-07 Manuel Lopez-Ibanez PR c++/28986 diff --git a/gcc/testsuite/gcc.dg/pr16194.c b/gcc/testsuite/gcc.dg/pr16194.c index 313f0eaa30d..eeb779eb66d 100644 --- a/gcc/testsuite/gcc.dg/pr16194.c +++ b/gcc/testsuite/gcc.dg/pr16194.c @@ -2,6 +2,7 @@ /* { dg-options "-O" } */ /* { dg-bogus "internal compiler error" "ICE" { target *-*-* } 0 } */ +#undef SKIP #define ASMDECL __asm (REG); #define CLOBBER_LIST : REG #define INP_CLOBBER_LIST : CLOBBER_LIST @@ -18,17 +19,15 @@ # define REG "6" #elif defined (__x86_64__) # define REG "rax" +#elif defined (__m68k__) +# define REG "%d0" #else - /* Make this test harmless for any target not recognized above. */ -# undef ASMDECL -# define ASMDECL -# define REG "conflict" -# undef CLOBBER_LIST -# define CLOBBER_LIST -# undef INP_CLOBBER_LIST -# define INP_CLOBBER_LIST +/* Make this test harmless for any target not recognized above. */ +# define SKIP 1 #endif +#ifndef SKIP + struct A { int a; @@ -47,7 +46,7 @@ struct C void bug (void) { register char* dst ASMDECL; - __asm__ ("":"=g"(*dst): : REG); /* { dg-error "conflict" } */ + __asm__ ("":"=g"(*dst): : REG); } /* The tree optimizers currently prevent us from finding an overlap - @@ -56,12 +55,22 @@ void bug (void) void bug2 (void) { register char* dst ASMDECL; - __asm__ ("": :"g"(*dst) CLOBBER_LIST); /* { dg-error "conflict" } */ + __asm__ ("": :"g"(*dst) CLOBBER_LIST); } void foo (void) { register struct C *dst ASMDECL; - __asm__ ("" : "=g"(dst->c.b[1].a) INP_CLOBBER_LIST); /* { dg-error "conflict" } */ + __asm__ ("" : "=g"(dst->c.b[1].a) INP_CLOBBER_LIST); } + +#else + +int main () +{ + return 0; +} + +#endif + diff --git a/gcc/tree-ssa-ter.c b/gcc/tree-ssa-ter.c index ca67f91e66e..c6b7ab39dce 100644 --- a/gcc/tree-ssa-ter.c +++ b/gcc/tree-ssa-ter.c @@ -393,6 +393,12 @@ is_replaceable_p (tree stmt) && FLOAT_TYPE_P (TREE_TYPE (GENERIC_TREE_OPERAND (stmt, 1)))) return false; + /* An assignment with a register variable on the RHS is not + replaceable. */ + if (TREE_CODE (GENERIC_TREE_OPERAND (stmt, 1)) == VAR_DECL + && DECL_HARD_REGISTER (GENERIC_TREE_OPERAND (stmt, 1))) + return false; + /* Calls to functions with side-effects cannot be replaced. */ if ((call_expr = get_call_expr_in (stmt)) != NULL_TREE) {