fix 16298

Richard Henderson rth@redhat.com
Tue Aug 24 22:19:00 GMT 2004


The analysis in the PR is correct.  We accepted just about anything
wrapped inside a CONST.  Which lead to later confusion, of course.


r~


        PR target/16298
        * config/i386/i386.c (legitimate_constant_p): Rework to not accept
        random codes within CONST.

Index: gcc/config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.715
diff -c -p -d -r1.715 i386.c
*** gcc/config/i386/i386.c	24 Aug 2004 00:30:48 -0000	1.715
--- gcc/config/i386/i386.c	24 Aug 2004 21:44:07 -0000
*************** darwin_local_data_pic (rtx disp)
*** 4824,4877 ****
  bool
  legitimate_constant_p (rtx x)
  {
-   rtx inner;
- 
    switch (GET_CODE (x))
      {
-     case SYMBOL_REF:
-       /* TLS symbols are not constant.  */
-       if (tls_symbolic_operand (x, Pmode))
- 	return false;
-       break;
- 
      case CONST:
!       inner = XEXP (x, 0);
! 
!       /* Offsets of TLS symbols are never valid.
! 	 Discourage CSE from creating them.  */
!       if (GET_CODE (inner) == PLUS
! 	  && tls_symbolic_operand (XEXP (inner, 0), Pmode))
! 	return false;
  
!       if (GET_CODE (inner) == PLUS)
  	{
! 	  if (GET_CODE (XEXP (inner, 1)) != CONST_INT)
  	    return false;
! 	  inner = XEXP (inner, 0);
  	}
  
!       if (TARGET_MACHO && darwin_local_data_pic (inner))
  	return true;
  
-       if (GET_CODE (inner) == MINUS)
- 	{
- 	  if (GET_CODE (XEXP (inner, 1)) != CONST_INT)
- 	    return false;
- 	  inner = XEXP (inner, 0);
- 	}
- 
        /* Only some unspecs are valid as "constants".  */
!       if (GET_CODE (inner) == UNSPEC)
! 	switch (XINT (inner, 1))
  	  {
  	  case UNSPEC_TPOFF:
  	  case UNSPEC_NTPOFF:
! 	    return local_exec_symbolic_operand (XVECEXP (inner, 0, 0), Pmode);
  	  case UNSPEC_DTPOFF:
! 	    return local_dynamic_symbolic_operand (XVECEXP (inner, 0, 0), Pmode);
  	  default:
  	    return false;
  	  }
        break;
  
      default:
--- 4824,4866 ----
  bool
  legitimate_constant_p (rtx x)
  {
    switch (GET_CODE (x))
      {
      case CONST:
!       x = XEXP (x, 0);
  
!       if (GET_CODE (x) == PLUS)
  	{
! 	  if (GET_CODE (XEXP (x, 1)) != CONST_INT)
  	    return false;
! 	  x = XEXP (x, 0);
  	}
  
!       if (TARGET_MACHO && darwin_local_data_pic (x))
  	return true;
  
        /* Only some unspecs are valid as "constants".  */
!       if (GET_CODE (x) == UNSPEC)
! 	switch (XINT (x, 1))
  	  {
  	  case UNSPEC_TPOFF:
  	  case UNSPEC_NTPOFF:
! 	    return local_exec_symbolic_operand (XVECEXP (x, 0, 0), Pmode);
  	  case UNSPEC_DTPOFF:
! 	    return local_dynamic_symbolic_operand (XVECEXP (x, 0, 0), Pmode);
  	  default:
  	    return false;
  	  }
+ 
+       /* We must have drilled down to a symbol.  */
+       if (!symbolic_operand (x, Pmode))
+ 	return false;
+       /* FALLTHRU */
+ 
+     case SYMBOL_REF:
+       /* TLS symbols are never valid.  */
+       if (tls_symbolic_operand (x, Pmode))
+ 	return false;
        break;
  
      default:



More information about the Gcc-patches mailing list