This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PR target/18910


On Sun, Jan 02, 2005 at 10:21:18AM +0100, Jan Hubicka wrote:
> !   if (GET_CODE (op1) == CONST && GET_CODE (XEXP (op1, 0)) == PLUS
> !       && GET_CODE (XEXP (XEXP (op1, 0), 0)) == SYMBOL_REF)
> !     model = SYMBOL_REF_TLS_MODEL (XEXP (XEXP (op1, 0), 0));
> !   else if (GET_CODE (op1) == SYMBOL_REF)
> !     model = SYMBOL_REF_TLS_MODEL (op1);
> !   else
> !     model = 0;
>     if (model)
>       {
>         op1 = legitimize_tls_address (op1, model, true);

I don't think this is right because legitimize_tls_address
doesn't handle the offset part properly.  

I've checked in the following revision.


r~


        * config/i386/i386.c (ix86_expand_move): Handle tls symbols
        with an offset.

Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.768
diff -c -p -d -r1.768 i386.c
*** config/i386/i386.c	5 Jan 2005 19:14:38 -0000	1.768
--- config/i386/i386.c	5 Jan 2005 20:18:32 -0000
*************** ix86_expand_move (enum machine_mode mode
*** 7472,7484 ****
    op0 = operands[0];
    op1 = operands[1];
  
!   model = GET_CODE (op1) == SYMBOL_REF ? SYMBOL_REF_TLS_MODEL (op1) : 0;
!   if (model)
      {
!       op1 = legitimize_tls_address (op1, model, true);
!       op1 = force_operand (op1, op0);
!       if (op1 == op0)
! 	return;
      }
  
    if (flag_pic && mode == Pmode && symbolic_operand (op1, Pmode))
--- 7472,7503 ----
    op0 = operands[0];
    op1 = operands[1];
  
!   if (GET_CODE (op1) == SYMBOL_REF)
      {
!       model = SYMBOL_REF_TLS_MODEL (op1);
!       if (model)
! 	{
! 	  op1 = legitimize_tls_address (op1, model, true);
! 	  op1 = force_operand (op1, op0);
! 	  if (op1 == op0)
! 	    return;
! 	}
!     }
!   else if (GET_CODE (op1) == CONST
! 	   && GET_CODE (XEXP (op1, 0)) == PLUS
! 	   && GET_CODE (XEXP (XEXP (op1, 0), 0)) == SYMBOL_REF)
!     {
!       model = SYMBOL_REF_TLS_MODEL (XEXP (XEXP (op1, 0), 0));
!       if (model)
! 	{
! 	  rtx addend = XEXP (XEXP (op1, 0), 1);
! 	  op1 = legitimize_tls_address (XEXP (XEXP (op1, 0), 0), model, true);
! 	  op1 = force_operand (op1, NULL);
! 	  op1 = expand_simple_binop (Pmode, PLUS, op1, addend,
! 				     op0, 1, OPTAB_DIRECT);
! 	  if (op1 == op0)
! 	    return;
! 	}
      }
  
    if (flag_pic && mode == Pmode && symbolic_operand (op1, Pmode))
Index: testsuite/gcc.dg/tls/opt-8.c
===================================================================
RCS file: testsuite/gcc.dg/tls/opt-8.c
diff -N testsuite/gcc.dg/tls/opt-8.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.dg/tls/opt-8.c	5 Jan 2005 20:26:48 -0000
***************
*** 0 ****
--- 1,13 ----
+ /* PR 18910 */
+ /* { dg-do compile } */
+ /* { dg-options "-O2" } */
+ 
+ static __thread void *foo [2];
+ void
+ test1 (void)
+ {
+   unsigned int s;
+ 
+   for (s = 0; s < 2; ++s)
+     foo [s] = &foo[s];
+ }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]