From patchwork Fri Oct 11 16:35:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 1175379 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-510791-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="PVkLG1r2"; 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 46qYV84P2Hz9sCJ for ; Sat, 12 Oct 2019 03:35:44 +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=qpzhKPx46EduMRp7UOwNHHNoJYs7J6+ kxuM4bUi6RVhRSvoDVkMQAz3t19YeL4i89ugZeraJCb0YQfDfCKVl5ozAoj7/TOh PBgCZ5rUMw6YGzHCvsqgmtyMLy+wXUGiy/G4C7If3RZ3CfqGgtBmIDyQmBEoPvwo GYtzRCrotPww= 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=AvG9LubtkENDrdIPv0lI7QC4DH4=; b=PVkLG 1r2EYLaPBMIo+yzpnvKmK5NY/Tbb1oZSgqF+/Vcp0KeBQQ40NLfRFsNXZueU6xkX 0BkLLR0TtESfxr4gRTYmF7Z3XfvSfE1+EJIUTsCNCHweRGUh8gdQDRP2hBfNelUy 70iyMjpCl4ffc9MfSfzUkk/j3sCnVPiWvCDuik= Received: (qmail 825 invoked by alias); 11 Oct 2019 16:35:38 -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 817 invoked by uid 89); 11 Oct 2019 16:35:37 -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=H*m:iii, H*MI:iii, lp64, tear X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 11 Oct 2019 16:35:36 +0000 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x9BGYCPj143118 for ; Fri, 11 Oct 2019 12:35:34 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2vjvpphrj2-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 11 Oct 2019 12:35:34 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 11 Oct 2019 17:35:32 +0100 Received: from b06avi18878370.portsmouth.uk.ibm.com (9.149.26.194) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 11 Oct 2019 17:35:29 +0100 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x9BGZSix15532348 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Oct 2019 16:35:28 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 19C2AA4067; Fri, 11 Oct 2019 16:35:28 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D0604A4065; Fri, 11 Oct 2019 16:35:27 +0000 (GMT) Received: from white.boeblingen.de.ibm.com (unknown [9.152.96.38]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 11 Oct 2019 16:35:27 +0000 (GMT) From: Ilya Leoshkevich To: gcc-patches@gcc.gnu.org, krebbel@linux.ibm.com Cc: rdapp@linux.ibm.com, stli@linux.ibm.com, Ilya Leoshkevich Subject: [PATCH] S/390: Run %a0:DI splitters only after reload Date: Fri, 11 Oct 2019 18:35:22 +0200 MIME-Version: 1.0 x-cbid: 19101116-0028-0000-0000-000003A93A47 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19101116-0029-0000-0000-0000246B4764 Message-Id: <20191011163522.12912-1-iii@linux.ibm.com> X-IsSubscribed: yes Bootstrapped and regtested on s390x-redhat-linux. gcc/ChangeLog: 2019-10-10 Ilya Leoshkevich * config/s390/s390.md: Run %a0:DI splitters only after reload. gcc/testsuite/ChangeLog: 2019-10-10 Ilya Leoshkevich * gcc.target/s390/load-thread-pointer-once.c: New test. --- gcc/config/s390/s390.md | 13 ++++++++++--- .../gcc.target/s390/load-thread-pointer-once.c | 12 ++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/s390/load-thread-pointer-once.c diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index 4f7bde6616b..1e6439d5fd6 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -1860,10 +1860,17 @@ *,*,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. + (define_split [(set (match_operand:DI 0 "register_operand" "") (match_operand:DI 1 "register_operand" ""))] - "TARGET_ZARCH && ACCESS_REG_P (operands[1])" + "TARGET_ZARCH && ACCESS_REG_P (operands[1]) && 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))] @@ -1873,7 +1880,7 @@ (define_split [(set (match_operand:DI 0 "register_operand" "") (match_operand:DI 1 "register_operand" ""))] - "TARGET_ZARCH && ACCESS_REG_P (operands[0]) + "TARGET_ZARCH && ACCESS_REG_P (operands[0]) && reload_completed && dead_or_set_p (insn, operands[1])" [(set (match_dup 3) (match_dup 2)) (set (match_dup 1) (lshiftrt:DI (match_dup 1) (const_int 32))) @@ -1884,7 +1891,7 @@ (define_split [(set (match_operand:DI 0 "register_operand" "") (match_operand:DI 1 "register_operand" ""))] - "TARGET_ZARCH && ACCESS_REG_P (operands[0]) + "TARGET_ZARCH && ACCESS_REG_P (operands[0]) && reload_completed && !dead_or_set_p (insn, operands[1])" [(set (match_dup 3) (match_dup 2)) (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32))) diff --git a/gcc/testsuite/gcc.target/s390/load-thread-pointer-once.c b/gcc/testsuite/gcc.target/s390/load-thread-pointer-once.c new file mode 100644 index 00000000000..21a5bfaa732 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/load-thread-pointer-once.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +__thread void *foo; + +void *bar() +{ + return (foo = __builtin_thread_pointer()); +} + +/* { dg-final { scan-assembler-times {\n\tear\t} 2 { target { lp64 } } } } */ +/* { dg-final { scan-assembler-times {\n\tear\t} 1 { target { ! lp64 } } } } */