This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[i386 PATCH] Mark __tls_get_addr call as pure
- From: Paolo Bonzini <paolo dot bonzini at lu dot unisi dot ch>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jan Hubicka <jh at suse dot cz>
- Date: Tue, 08 May 2007 11:50:21 +0200
- Subject: [i386 PATCH] Mark __tls_get_addr call as pure
- Reply-to: bonzini at gnu dot org
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)