From patchwork Fri Oct 19 08:39:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 986620 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-487874-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="OhatnDfg"; 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 42bzrF27yrz9sB7 for ; Fri, 19 Oct 2018 19:40:10 +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=IL3FnhhsplbvWr6Xa9+kWc29Zc6s5kY VOymaur4entnxOxaIcfv0j8gMM8ileqjED99K7m5ZsKmUCAuVMW63N0jmEuUZbK6 yNiLkB18IpLotYSE/C7bAiisGf+8H8IK+eLfVZ6JYwpOlm8ZzgWjhL5k2R5ru55u LjVomdfyF4ow= 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=w9zC0RUaD4Z4cpHak2aRAEvVEhw=; b=Ohatn DfgS7/BFYN360khwhqqpy2VZTJd9vMNiJsC+kNDdBJpoQDQHRGtwTMODx3cgPEw4 mz0vO5H9OVYXt12rr8eOfJN8sF2HHUf0EwmZ4ql76Ri1L9DcJ2rIhtj3J0aWT9Xt AVurO7zNUGi2nTQeHhUOCGI8Dv/pTwp5OIuihA= Received: (qmail 27933 invoked by alias); 19 Oct 2018 08:40:03 -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 27921 invoked by uid 89); 19 Oct 2018 08:40:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ADVERT2, KAM_SHORT, KHOP_DYNAMIC, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=REF, SYMBOL_REF 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; Fri, 19 Oct 2018 08:40:00 +0000 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9J8dcwK045530 for ; Fri, 19 Oct 2018 04:39:59 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2n7bub096r-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 19 Oct 2018 04:39:58 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 19 Oct 2018 09:39:57 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) 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) Fri, 19 Oct 2018 09:39:54 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9J8dqkv6750564 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 19 Oct 2018 08:39:52 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B856011C052; Fri, 19 Oct 2018 08:39:52 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8CA7A11C04A; Fri, 19 Oct 2018 08:39:52 +0000 (GMT) Received: from white.boeblingen.de.ibm.com (unknown [9.152.98.107]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 19 Oct 2018 08:39:52 +0000 (GMT) From: Ilya Leoshkevich To: gcc-patches@gcc.gnu.org Cc: krebbel@linux.ibm.com, rdapp@linux.ibm.com, Ilya Leoshkevich Subject: [PATCH] S/390: Make "b" constraint match literal pool references Date: Fri, 19 Oct 2018 10:39:49 +0200 MIME-Version: 1.0 x-cbid: 18101908-0016-0000-0000-0000021564CE X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18101908-0017-0000-0000-0000326D0B6E Message-Id: <20181019083949.6801-1-iii@linux.ibm.com> X-IsSubscribed: yes Improves the code generation by getting rid of redundant LAs, as seen in the following example: - la %r1,0(%r13) - lg %r4,0(%r1) + lg %r4,0(%r13) Also allows to proceed with the merge of movdi_64 and movdi_larl. Currently LRA decides to spill literal pool references back to the literal pool, because it preliminarily chooses alternatives with CT_MEMORY constraints without calling satisfies_memory_constraint_p (). Later on it notices that the constraint is wrong and fixes it by spilling. The constraint in this case is "b", and the operand is a literal pool reference. There is no reason to reject them. The current behavior was introduced, apparently unintentionally, by https://gcc.gnu.org/ml/gcc-patches/2010-09/msg00812.html The patch affects a little bit more than mentioned in the subject, because it changes s390_loadrelative_operand_p (), which is called not only for checking the "b" constraint. However, the only caller for which it should really not accept literal pool references is s390_check_qrst_address (), so it was changed to explicitly do so. gcc/ChangeLog: 2018-10-18 Ilya Leoshkevich * config/s390/s390.c (s390_loadrelative_operand_p): Accept literal pool references. (s390_check_qrst_address): Adapt to the new behavior of s390_loadrelative_operand_p (). gcc/testsuite/ChangeLog: 2018-10-18 Ilya Leoshkevich * gcc.target/s390/litpool-int.c: New test. --- gcc/config/s390/s390.c | 9 +++++---- gcc/testsuite/gcc.target/s390/litpool-int.c | 12 ++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/s390/litpool-int.c diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index ed307c3598b..0b7e44b62e1 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -3110,8 +3110,7 @@ s390_legitimate_address_without_index_p (rtx op) Valid addresses are single references or a sum of a reference and a constant integer. Return these parts in SYMREF and ADDEND. You can pass NULL in REF and/or ADDEND if you are not interested in these - values. Literal pool references are *not* considered symbol - references. */ + values. */ static bool s390_loadrelative_operand_p (rtx addr, rtx *symref, HOST_WIDE_INT *addend) @@ -3130,7 +3129,7 @@ s390_loadrelative_operand_p (rtx addr, rtx *symref, HOST_WIDE_INT *addend) addr = XEXP (addr, 0); } - if ((GET_CODE (addr) == SYMBOL_REF && !CONSTANT_POOL_ADDRESS_P (addr)) + if (GET_CODE (addr) == SYMBOL_REF || (GET_CODE (addr) == UNSPEC && (XINT (addr, 1) == UNSPEC_GOTENT || XINT (addr, 1) == UNSPEC_PLT))) @@ -3153,6 +3152,7 @@ s390_loadrelative_operand_p (rtx addr, rtx *symref, HOST_WIDE_INT *addend) static int s390_check_qrst_address (char c, rtx op, bool lit_pool_ok) { + rtx symref; struct s390_address addr; bool decomposed = false; @@ -3161,7 +3161,8 @@ s390_check_qrst_address (char c, rtx op, bool lit_pool_ok) /* This check makes sure that no symbolic address (except literal pool references) are accepted by the R or T constraints. */ - if (s390_loadrelative_operand_p (op, NULL, NULL)) + if (s390_loadrelative_operand_p (op, &symref, NULL) + && (!lit_pool_ok || !CONSTANT_POOL_ADDRESS_P (symref))) return 0; /* Ensure literal pool references are only accepted if LIT_POOL_OK. */ diff --git a/gcc/testsuite/gcc.target/s390/litpool-int.c b/gcc/testsuite/gcc.target/s390/litpool-int.c new file mode 100644 index 00000000000..a6bf0c01f4f --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/litpool-int.c @@ -0,0 +1,12 @@ +/* Test that we do not generate useless LAs. */ + +/* { dg-do compile } */ +/* { dg-options "-march=z10 -O1" } */ + +int a; + +void b() +{ + a /= 100; + /* { dg-final { scan-assembler-not {(?n)\n\tla\t%r\d+,.+\(%r13\)\n} } } */ +}