Commit 8f4f98f6 by Ilya Leoshkevich Committed by Ilya Leoshkevich

S/390: Use UNSPEC_GET_TP for thread pointer loads

gcc/ChangeLog:

2019-10-24  Ilya Leoshkevich  <iii@linux.ibm.com>

	* config/s390/s390.c (s390_get_thread_pointer): Use
	gen_get_thread_pointer.
	(s390_expand_split_stack_prologue): Likewise.
	* config/s390/s390.md (UNSPEC_GET_TP): New UNSPEC.
	(*get_tp_31): New 31-bit splitter for UNSPEC_GET_TP.
	(*get_tp_64): New 64-bit splitter for UNSPEC_GET_TP.
	(get_thread_pointer<mode>): Use UNSPEC_GET_TP, use
	parameterized name.

gcc/testsuite/ChangeLog:

2019-10-24  Ilya Leoshkevich  <iii@linux.ibm.com>

	* gcc.target/s390/load-thread-pointer-once-2.c: New test.

From-SVN: r277368
parent d136595d
2019-10-24 Ilya Leoshkevich <iii@linux.ibm.com>
* config/s390/s390.c (s390_get_thread_pointer): Use
gen_get_thread_pointer.
(s390_expand_split_stack_prologue): Likewise.
* config/s390/s390.md (UNSPEC_GET_TP): New UNSPEC.
(*get_tp_31): New 31-bit splitter for UNSPEC_GET_TP.
(*get_tp_64): New 64-bit splitter for UNSPEC_GET_TP.
(get_thread_pointer<mode>): Use UNSPEC_GET_TP, use
parameterized name.
2019-10-24 Richard Biener <rguenther@suse.de> 2019-10-24 Richard Biener <rguenther@suse.de>
* tree-vect-slp.c (vect_analyze_slp): When reduction group * tree-vect-slp.c (vect_analyze_slp): When reduction group
...@@ -5106,7 +5106,8 @@ s390_get_thread_pointer (void) ...@@ -5106,7 +5106,8 @@ s390_get_thread_pointer (void)
{ {
rtx tp = gen_reg_rtx (Pmode); rtx tp = gen_reg_rtx (Pmode);
emit_move_insn (tp, gen_rtx_REG (Pmode, TP_REGNUM)); emit_insn (gen_get_thread_pointer (Pmode, tp));
mark_reg_pointer (tp, BITS_PER_WORD); mark_reg_pointer (tp, BITS_PER_WORD);
return tp; return tp;
...@@ -11711,7 +11712,7 @@ s390_expand_split_stack_prologue (void) ...@@ -11711,7 +11712,7 @@ s390_expand_split_stack_prologue (void)
/* Get thread pointer. r1 is the only register we can always destroy - r0 /* Get thread pointer. r1 is the only register we can always destroy - r0
could contain a static chain (and cannot be used to address memory could contain a static chain (and cannot be used to address memory
anyway), r2-r6 can contain parameters, and r6-r15 are callee-saved. */ anyway), r2-r6 can contain parameters, and r6-r15 are callee-saved. */
emit_move_insn (r1, gen_rtx_REG (Pmode, TP_REGNUM)); emit_insn (gen_get_thread_pointer (Pmode, r1));
/* Aim at __private_ss. */ /* Aim at __private_ss. */
guard = gen_rtx_MEM (Pmode, plus_constant (Pmode, r1, psso)); guard = gen_rtx_MEM (Pmode, plus_constant (Pmode, r1, psso));
......
...@@ -105,6 +105,7 @@ ...@@ -105,6 +105,7 @@
; TLS support ; TLS support
UNSPEC_TLSLDM_NTPOFF UNSPEC_TLSLDM_NTPOFF
UNSPEC_TLS_LOAD UNSPEC_TLS_LOAD
UNSPEC_GET_TP
; String Functions ; String Functions
UNSPEC_SRST UNSPEC_SRST
...@@ -1860,23 +1861,35 @@ ...@@ -1860,23 +1861,35 @@
*,*,yes") *,*,yes")
]) ])
; Splitters for loading/storing TLS pointers from/to %a0:DI. ; Splitters for loading TLS pointer from UNSPEC_GET_TP.
; Do this only during split2, which runs after reload. At the point when split1 ; UNSPEC_GET_TP is used instead of %a0:P, since the latter is a hard register,
; runs, some of %a0:DI occurrences might be nested inside other rtxes and thus ; and those are not handled by Partial Redundancy Elimination (gcse.c), which
; not matched. As a result, only some occurrences will be split, which will ; results in generation of redundant thread pointer loads.
; prevent CSE. At the point when split2 runs, reload will have ensured that no
; nested references exist.
(define_split (define_insn_and_split "*get_tp_31"
[(set (match_operand:DI 0 "register_operand" "") [(set (match_operand:SI 0 "register_operand" "=r")
(match_operand:DI 1 "register_operand" ""))] (unspec:SI [(match_operand:SI 1 "register_operand" "t")]
"TARGET_ZARCH && ACCESS_REG_P (operands[1]) && reload_completed" UNSPEC_GET_TP))]
""
"#"
"&& reload_completed"
[(set (match_dup 0) (match_dup 1))])
(define_insn_and_split "*get_tp_64"
[(set (match_operand:DI 0 "register_operand" "=r")
(unspec:DI [(match_operand:DI 1 "register_operand" "t")]
UNSPEC_GET_TP))]
"TARGET_ZARCH"
"#"
"&& reload_completed"
[(set (match_dup 2) (match_dup 3)) [(set (match_dup 2) (match_dup 3))
(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32))) (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
(set (strict_low_part (match_dup 2)) (match_dup 4))] (set (strict_low_part (match_dup 2)) (match_dup 4))]
"operands[2] = gen_lowpart (SImode, operands[0]); "operands[2] = gen_lowpart (SImode, operands[0]);
s390_split_access_reg (operands[1], &operands[4], &operands[3]);") s390_split_access_reg (operands[1], &operands[4], &operands[3]);")
; Splitters for storing TLS pointer to %a0:DI.
(define_split (define_split
[(set (match_operand:DI 0 "register_operand" "") [(set (match_operand:DI 0 "register_operand" "")
(match_operand:DI 1 "register_operand" ""))] (match_operand:DI 1 "register_operand" ""))]
...@@ -10520,8 +10533,9 @@ ...@@ -10520,8 +10533,9 @@
;;- Thread-local storage support. ;;- Thread-local storage support.
;; ;;
(define_expand "get_thread_pointer<mode>" (define_expand "@get_thread_pointer<mode>"
[(set (match_operand:P 0 "nonimmediate_operand" "") (reg:P TP_REGNUM))] [(set (match_operand:P 0 "nonimmediate_operand" "")
(unspec:P [(reg:P TP_REGNUM)] UNSPEC_GET_TP))]
"" ""
"") "")
......
2019-10-24 Ilya Leoshkevich <iii@linux.ibm.com>
* gcc.target/s390/load-thread-pointer-once-2.c: New test.
2019-10-24 Richard Biener <rguenther@suse.de> 2019-10-24 Richard Biener <rguenther@suse.de>
* gcc.dg/vect/slp-reduc-9.c: New testcase. * gcc.dg/vect/slp-reduc-9.c: New testcase.
......
/* { dg-do compile } */
/* { dg-options "-O3" } */
extern void c(void *);
void a(void)
{
void *b = __builtin_thread_pointer();
if (b)
c(b);
}
/* { dg-final { scan-assembler-times {\n\tear\t} 2 { target { lp64 } } } } */
/* { dg-final { scan-assembler-times {\n\tear\t} 1 { target { ! lp64 } } } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment