[PATCH] Backport fix for 29877 to 4.2

Andrew MacLeod amacleod@redhat.com
Fri Mar 9 19:34:00 GMT 2007



I ported this patch back to 4.2 and applied it.  Bootstrapped and
regression tested on build-i686-pc-linux-gnu.  Someone running arm-linux
might want to run this just to verify it since the original defect was
opened against that target. The listing looks fine though, and the patch
shouldn't affect anything else. TER does not perform the incorrect
expression substitution with this patch.

Andrew


2006-03-09  Mark Shinwell  <shinwell@codesourcery.com>
	    Andrew MacLeod  <amacleod@redhat.com>

	PR tree-optimization/29877
	* tree-outof-ssa.c (check_replaceable): Don't allow TER to replace
	an expression if the RHS is a register variable.

	testsuite
	* gcc.dg/pr16194.c: Skip test entirely if we don't know the name of
	a hard register for the target concerned.


Index: gcc/tree-outof-ssa.c
===================================================================
*** gcc/tree-outof-ssa.c	(revision 122559)
--- gcc/tree-outof-ssa.c	(working copy)
*************** check_replaceable (temp_expr_table_p tab
*** 1577,1582 ****
--- 1577,1588 ----
    if (flag_float_store && FLOAT_TYPE_P (TREE_TYPE (TREE_OPERAND (stmt, 1))))
      return false;
  
+   /* An assignment with a register variable on the RHS is not
+      replaceable.  */
+   if (TREE_CODE (TREE_OPERAND (stmt, 1)) == VAR_DECL
+      && DECL_HARD_REGISTER (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)
      {
Index: gcc/testsuite/gcc.dg/pr16194.c
===================================================================
*** gcc/testsuite/gcc.dg/pr16194.c	(revision 122559)
--- gcc/testsuite/gcc.dg/pr16194.c	(working copy)
***************
*** 2,7 ****
--- 2,8 ----
  /* { 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,34 ****
  # define REG "6"
  #elif defined (__x86_64__)
  # define REG "rax"
  #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
  #endif
  
  struct A
  {
    int a;
--- 19,33 ----
  # 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.  */
! # define SKIP 1
  #endif
  
+ #ifndef SKIP
+ 
  struct A
  {
    int a;
*************** struct C
*** 47,53 ****
  void bug (void)
  {
    register char* dst ASMDECL;
!   __asm__ ("":"=g"(*dst): : REG); /* { dg-error "conflict" } */
  }
  
  /* The tree optimizers currently prevent us from finding an overlap -
--- 46,52 ----
  void bug (void)
  {
    register char* dst ASMDECL;
!   __asm__ ("":"=g"(*dst): : REG);
  }
  
  /* The tree optimizers currently prevent us from finding an overlap -
*************** foo (void)
*** 65,67 ****
--- 64,76 ----
    register struct C *dst ASMDECL;
    __asm__ ("" : "=g"(dst->c.b[1].a) INP_CLOBBER_LIST);
  }
+ 
+ #else
+ 
+ int main ()
+ {
+   return 0;
+ }
+ 
+ #endif
+ 





More information about the Gcc-patches mailing list