From patchwork Wed Oct 23 11:02:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 1182058 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-511566-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="sydpIGdj"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46ynXj4CnGz9sP3 for ; Wed, 23 Oct 2019 22:03:01 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:mime-version:content-transfer-encoding :message-id; q=dns; s=default; b=a1m7mJb/Io2YJ8QhR3qGamhwrfI0L1a S2/neDvuQXm9vu/BujbejTie4qa5lzuGF485e/gPkSwH3gJ5bxWRmphrNtTtbSLj WnyO0FBYC2V6C5SFePTymR20WX/7iJErrCoTsSjuBES8OHgxRA7dKX8tPwMVumMY w7L/NcXHZ8cg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:mime-version:content-transfer-encoding :message-id; s=default; bh=RKoJ4blfV8QS9FyAZZZvgTH9z3I=; b=sydpI Gdjvb8WL9+7WNU2BqEteO5+1DX/+ie9lknZ9+tBomrfQo1+neyZ17Fk4mXqSRqqe Jzw4X6R/h8wH9CxuEfnS7bIm4m71n/Otm6WOTZma4oLDFUcJn7vdk3Gwc7fDihXW BuXAm4tZ/OZakHulKyMqxcAdoxPl7e6mnuWH5Y= Received: (qmail 90213 invoked by alias); 23 Oct 2019 11:02:54 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 89860 invoked by uid 89); 23 Oct 2019 11:02:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=1056, splitter X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Oct 2019 11:02:52 +0000 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x9NB2UMM034287 for ; Wed, 23 Oct 2019 07:02:50 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2vtm533dbt-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 23 Oct 2019 07:02:50 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 23 Oct 2019 12:02:48 +0100 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 23 Oct 2019 12:02:46 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x9NB29IN36635078 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Oct 2019 11:02:09 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 43E194C040; Wed, 23 Oct 2019 11:02:42 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 084BC4C059; Wed, 23 Oct 2019 11:02:42 +0000 (GMT) Received: from white.boeblingen.de.ibm.com (unknown [9.152.96.86]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 23 Oct 2019 11:02:41 +0000 (GMT) From: Ilya Leoshkevich To: gcc-patches@gcc.gnu.org, krebbel@linux.ibm.com Cc: uweigand@de.ibm.com, stli@linux.ibm.com, Ilya Leoshkevich Subject: [PATCH] S/390: Use UNSPEC_GET_TP for thread pointer loads Date: Wed, 23 Oct 2019 13:02:35 +0200 MIME-Version: 1.0 x-cbid: 19102311-0016-0000-0000-000002BC0A58 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19102311-0017-0000-0000-0000331D497D Message-Id: <20191023110235.11457-1-iii@linux.ibm.com> X-IsSubscribed: yes Boostrapped and regtested on s390x-redhat-linux. gcc/ChangeLog: 2019-10-21 Ilya Leoshkevich * 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): Use UNSPEC_GET_TP, use parameterized name. gcc/testsuite/ChangeLog: 2019-10-21 Ilya Leoshkevich * gcc.target/s390/load-thread-pointer-once-2.c: New test. --- gcc/config/s390/s390.c | 5 ++- gcc/config/s390/s390.md | 38 +++++++++++++------ .../s390/load-thread-pointer-once-2.c | 14 +++++++ 3 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 gcc/testsuite/gcc.target/s390/load-thread-pointer-once-2.c diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 9fed7d3b99f..151b80da0b3 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -5106,7 +5106,8 @@ s390_get_thread_pointer (void) { 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); return tp; @@ -11711,7 +11712,7 @@ s390_expand_split_stack_prologue (void) /* 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 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. */ guard = gen_rtx_MEM (Pmode, plus_constant (Pmode, r1, psso)); diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index 1e6439d5fd6..e3881d07f2b 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -105,6 +105,7 @@ ; TLS support UNSPEC_TLSLDM_NTPOFF UNSPEC_TLS_LOAD + UNSPEC_GET_TP ; String Functions UNSPEC_SRST @@ -1860,23 +1861,35 @@ *,*,yes") ]) -; Splitters for loading/storing TLS pointers from/to %a0:DI. -; Do this only during split2, which runs after reload. At the point when split1 -; runs, some of %a0:DI occurrences might be nested inside other rtxes and thus -; not matched. As a result, only some occurrences will be split, which will -; prevent CSE. At the point when split2 runs, reload will have ensured that no -; nested references exist. +; Splitters for loading TLS pointer from UNSPEC_GET_TP. +; UNSPEC_GET_TP is used instead of %a0:P, since the latter is a hard register, +; and those are not handled by Partial Redundancy Elimination (gcse.c), which +; results in generation of redundant thread pointer loads. -(define_split - [(set (match_operand:DI 0 "register_operand" "") - (match_operand:DI 1 "register_operand" ""))] - "TARGET_ZARCH && ACCESS_REG_P (operands[1]) && reload_completed" +(define_insn_and_split "*get_tp_31" + [(set (match_operand:SI 0 "register_operand" "=r") + (unspec:SI [(match_operand:SI 1 "register_operand" "t")] + 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 0) (ashift:DI (match_dup 0) (const_int 32))) (set (strict_low_part (match_dup 2)) (match_dup 4))] "operands[2] = gen_lowpart (SImode, operands[0]); s390_split_access_reg (operands[1], &operands[4], &operands[3]);") +; Splitters for storing TLS pointer to %a0:DI. + (define_split [(set (match_operand:DI 0 "register_operand" "") (match_operand:DI 1 "register_operand" ""))] @@ -10520,8 +10533,9 @@ ;;- Thread-local storage support. ;; -(define_expand "get_thread_pointer" - [(set (match_operand:P 0 "nonimmediate_operand" "") (reg:P TP_REGNUM))] +(define_expand "@get_thread_pointer" + [(set (match_operand:P 0 "nonimmediate_operand" "") + (unspec:P [(reg:P TP_REGNUM)] UNSPEC_GET_TP))] "" "") diff --git a/gcc/testsuite/gcc.target/s390/load-thread-pointer-once-2.c b/gcc/testsuite/gcc.target/s390/load-thread-pointer-once-2.c new file mode 100644 index 00000000000..36b1ed8800f --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/load-thread-pointer-once-2.c @@ -0,0 +1,14 @@ +/* { 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 } } } } */