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]

[i386 PATCH] Mark __tls_get_addr call as pure


This is the same that is done by the rs6000 backend. Together with other patches I posted, it helps getting rid of libcall notes on i386 (x86_64 actually).

I would appreciate more testing since I don't have an x86_64 backend. I bootstrapped it on i686-pc-linux-gnu just to make sure I didn't screw up something, and tested on the test case Steven posted earlier:

/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
/* { dg-options "-O2 -fno-tree-pre -fno-tree-loop-im -fpic ftls-model=local-dynamic" } */
/* { dg-final { scan-assembler-times "__tls_get_addr" 1 } } */


typedef struct { int a, b; } X;
static __thread X *x, *y;

int foo (void)
{
 int i;

 while (i < 128)
   {
     i += x->a;
     i += y->b;
   }

 return i;
}

Ok if somebody confirms it passes on x86_64?

I suggest testers to remove this line from libgomp/configure.tgt before testing:

XCFLAGS="${XCFLAGS} -ftls-model=initial-exec"

otherwise the code would not be stressed enough.

Paolo
2007-05-08  Paolo Bonzini  <bonzini@gnu.org>

	* config/i386/i386.c (legitimize_tls_address): Mark __tls_get_addr
	calls as pure.

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 124539)
+++ config/i386/i386.c	(working copy)
@@ -7302,6 +7302,7 @@ legitimize_tls_address (rtx x, enum tls_
 	  insns = get_insns ();
 	  end_sequence ();
 
+	  CONST_OR_PURE_CALL_P (insns) = 1;
 	  emit_libcall_block (insns, dest, rax, x);
 	}
       else if (TARGET_64BIT && TARGET_GNU2_TLS)
@@ -7332,6 +7333,7 @@ legitimize_tls_address (rtx x, enum tls_
 
 	  note = gen_rtx_EXPR_LIST (VOIDmode, const0_rtx, NULL);
 	  note = gen_rtx_EXPR_LIST (VOIDmode, ix86_tls_get_addr (), note);
+	  CONST_OR_PURE_CALL_P (insns) = 1;
 	  emit_libcall_block (insns, base, rax, note);
 	}
       else if (TARGET_64BIT && TARGET_GNU2_TLS)

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