From patchwork Sun Jun 19 13:25:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 637685 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3rXZVp1j6Xz9t0M for ; Sun, 19 Jun 2016 23:25:37 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=XJYWN8gJ; dkim-atps=neutral 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:message-id:references:in-reply-to :content-type:mime-version; q=dns; s=default; b=qx7LnMomnMdSsLX8 +zbWrNb/txlRnS2tSTJjnDhAmMO3hOJzG7D/dTzFDYa+QoLHDBmZP1B4SyIQ7t+h ta3wmcIf/xSqLCan4+BAwRzAmfri1jXB2CE6EN9XPAo2AkNEJBZw4jBzQXpRFlzo dWRtAAAX0zcZZfYP5McAzQnO2N0= 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:message-id:references:in-reply-to :content-type:mime-version; s=default; bh=iIi24afEfHyU7+HYgmpJEo J5YqM=; b=XJYWN8gJcB/keSS+R+T2/mT4JfyAl/M50Go5xUA4SxXjb1cdfihg3/ d/vSMft4OS4800YRgFVURqbHSIUMGfZfjqP+dtfysoCr9ls1hBfqIFAlYolA1Yp/ NnVeW0xW8IzYvw9WCJV7pKDZOzpLT0oBr4b6BvYa0HwLRsnhqdmkQ= Received: (qmail 21800 invoked by alias); 19 Jun 2016 13:25:29 -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 21786 invoked by uid 89); 19 Jun 2016 13:25:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=Hx-spam-relays-external:15.1.517.7, H*RU:15.1.517.7, H*r:ip*15.1.517.7, berndedlingerhotmailde X-HELO: SNT004-OMC3S46.hotmail.com Received: from snt004-omc3s46.hotmail.com (HELO SNT004-OMC3S46.hotmail.com) (65.54.51.83) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA256 encrypted) ESMTPS; Sun, 19 Jun 2016 13:25:18 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com ([65.55.90.135]) by SNT004-OMC3S46.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Sun, 19 Jun 2016 06:25:16 -0700 Received: from HE1EUR01FT022.eop-EUR01.prod.protection.outlook.com (10.152.0.58) by HE1EUR01HT133.eop-EUR01.prod.protection.outlook.com (10.152.0.216) with Microsoft SMTP Server (TLS) id 15.1.517.7; Sun, 19 Jun 2016 13:25:09 +0000 Received: from AM4PR0701MB2162.eurprd07.prod.outlook.com (10.152.0.57) by HE1EUR01FT022.mail.protection.outlook.com (10.152.0.165) with Microsoft SMTP Server (TLS) id 15.1.517.7 via Frontend Transport; Sun, 19 Jun 2016 13:25:09 +0000 Received: from AM4PR0701MB2162.eurprd07.prod.outlook.com ([10.167.132.147]) by AM4PR0701MB2162.eurprd07.prod.outlook.com ([10.167.132.147]) with mapi id 15.01.0517.014; Sun, 19 Jun 2016 13:25:08 +0000 From: Bernd Edlinger To: Jakub Jelinek , Jeff Law CC: "gcc-patches@gcc.gnu.org" , Vladimir Makarov , Richard Biener Subject: [PING**2] [PATCH] Fix asm X constraint (PR inline-asm/59155) Date: Sun, 19 Jun 2016 13:25:08 +0000 Message-ID: References: <5755AD05.4010608@redhat.com> <20160606180128.GC7387@tucnak.redhat.com> <20160606180845.GD7387@tucnak.redhat.com> <20160606194047.GF7387@tucnak.redhat.com> <74b7fd4b-e060-c3e8-16bb-9f529a7dc4b2@redhat.com> <20160609164304.GT7387@tucnak.redhat.com> <20160609164545.GU7387@tucnak.redhat.com> In-Reply-To: authentication-results: spf=softfail (sender IP is 25.152.0.57) smtp.mailfrom=hotmail.de; redhat.com; dkim=none (message not signed) header.d=none; redhat.com; dmarc=none action=none header.from=hotmail.de; received-spf: SoftFail (protection.outlook.com: domain of transitioning hotmail.de discourages use of 25.152.0.57 as permitted sender) x-ms-exchange-messagesentrepresentingtype: 1 x-eopattributedmessage: 0 x-forefront-antispam-report: CIP:25.152.0.57; IPV:NLI; CTRY:GB; EFV:NLI; SFV:NSPM; SFS:(10019020)(98900003); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1EUR01HT133; H:AM4PR0701MB2162.eurprd07.prod.outlook.com; FPR:; SPF:None; CAT:NONE; LANG:en; CAT:NONE; x-ms-office365-filtering-correlation-id: dd981885-4286-483d-c3a5-08d3984521e7 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(1601124038)(5061506196)(5061507196)(1603103041)(1601125047); SRVR:HE1EUR01HT133; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(432015012)(102415321)(82015046); SRVR:HE1EUR01HT133; BCL:0; PCL:0; RULEID:; SRVR:HE1EUR01HT133; x-forefront-prvs: 09781D4C35 MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jun 2016 13:25:08.5580 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR01HT133 Hi, ping... As this discussion did not make any progress, I just attached the latest version of my patch with the the changes that Vladimir proposed. Boot-strapped and reg-tested again on x86_64-linux-gnu. Is it OK for the trunk? Thanks Bernd. On 06/10/16 16:13, Bernd Edlinger wrote: > On 06/09/16 18:45, Jakub Jelinek wrote: >> On Thu, Jun 09, 2016 at 06:43:04PM +0200, Jakub Jelinek wrote: >>> Yes, I'm all in favor in disabling X constraint for inline asm. >>> Especially if people actually try to print it as well, rather than >>> make it >>> unused. That is a sure path to ICEs. >> >> Though, on the other side, even our documentation mentions >> asm volatile ("mtfsf 255,%1" : "=X"(sum): "f"(fpenv)); >> So perhaps we need to error just in case such an argument is printed? > > note that "=X" is also introduced internally in this asm statement: > > asm ("cmpl %2, 0" : "=@ccz"(z), "=@ccb"(b): "r"(i)); > > see i386.c, ix86_md_asm_adjust. > > The first =@cc is replaced by "=Bf" constraint but any > further =@cc are replaced by "=X" and scratch operand. > > Printing the "=X" scratch is harmless, but printing the "=Bf" causes > another ICE, I shall submit a follow up patch for that: > asm ("# %0" : "=@ccz"(z)); > > test.c:6:1: internal compiler error: in print_reg, at > config/i386/i386.c:17193 > } > ^ > 0xedfc30 print_reg(rtx_def*, int, _IO_FILE*) > ../../gcc-trunk/gcc/config/i386/i386.c:17189 > 0xf048a4 ix86_print_operand(_IO_FILE*, rtx_def*, int) > ../../gcc-trunk/gcc/config/i386/i386.c:17867 > 0x8bf87c output_operand(rtx_def*, int) > ../../gcc-trunk/gcc/final.c:3847 > 0x8c00ee output_asm_insn(char const*, rtx_def**) > ../../gcc-trunk/gcc/final.c:3763 > 0x8c1f9c final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*) > ../../gcc-trunk/gcc/final.c:2628 > 0x8c25c9 final(rtx_insn*, _IO_FILE*, int) > ../../gcc-trunk/gcc/final.c:2045 > 0x8c2da9 rest_of_handle_final > ../../gcc-trunk/gcc/final.c:4445 > 0x8c2da9 execute > ../../gcc-trunk/gcc/final.c:4520 > > > Well, regarding the X constraint, I do think that > it's definitely OK to use different rules if it is > used in asms vs. when if it is used internally in .md files. > > The patch handles X in asms to be just a synonym to the g constraint, > except that g allows only GENERAL_REGS and X allows ALL_REGS. > > What I am not sure of, is if X should allow more than g in terms of > CONSTANT_P. I think it should not, because probably the CONSTANT_P > handling in general_operand is likely smarter than that of the i > constraint. > > > Bernd. gcc: 2016-05-23 Bernd Edlinger PR inline-asm/59155 * lra-constraints.c (process_alt_operands): Allow ALL_REGS. * recog.c (asm_operand_ok): Handle X constraint. testsuite: 2016-05-23 Bernd Edlinger PR inline-asm/59155 * gcc.dg/torture/pr59155-1.c: New test. * gcc.dg/torture/pr59155-2.c: New test. * gcc.dg/torture/pr59155-3.c: New test. Index: gcc/lra-constraints.c =================================================================== --- gcc/lra-constraints.c (revision 237133) +++ gcc/lra-constraints.c (working copy) @@ -1854,8 +1854,9 @@ process_alt_operands (int only_alternative) if (curr_static_id->operand_alternative[opalt_num].anything_ok) { /* Fast track for no constraints at all. */ - curr_alt[nop] = NO_REGS; - CLEAR_HARD_REG_SET (curr_alt_set[nop]); + curr_alt[nop] = ALL_REGS; + COPY_HARD_REG_SET (curr_alt_set[nop], + reg_class_contents[ALL_REGS]); curr_alt_win[nop] = true; curr_alt_match_win[nop] = false; curr_alt_offmemok[nop] = false; Index: gcc/recog.c =================================================================== --- gcc/recog.c (revision 237133) +++ gcc/recog.c (working copy) @@ -1778,6 +1778,10 @@ asm_operand_ok (rtx op, const char *constraint, co result = 1; break; + case 'X': + if (scratch_operand (op, VOIDmode)) + result = 1; + /* ... fall through ... */ case 'g': if (general_operand (op, VOIDmode)) result = 1; Index: gcc/testsuite/gcc.dg/torture/pr59155-1.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr59155-1.c (revision 0) +++ gcc/testsuite/gcc.dg/torture/pr59155-1.c (working copy) @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +double f(double x){ + asm volatile("":"+X"(x)); + return x; +} +double g(double x,double y){ + return f(f(x)+f(y)); +} Index: gcc/testsuite/gcc.dg/torture/pr59155-2.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr59155-2.c (revision 0) +++ gcc/testsuite/gcc.dg/torture/pr59155-2.c (working copy) @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +double f(double x){ + asm volatile("":"+X"(x)); + return x; +} +double g(){ + return f(1.); +} Index: gcc/testsuite/gcc.dg/torture/pr59155-3.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr59155-3.c (revision 0) +++ gcc/testsuite/gcc.dg/torture/pr59155-3.c (working copy) @@ -0,0 +1,27 @@ +void +noprop1 (int **x, int y, int z) +{ + int *ptr = *x + y * z / 11; + asm volatile ("noprop1 %0" : : "X" (*ptr)); +} + +void +noprop2 (int **x, int y, int z) +{ + int *ptr = *x + y * z / 11; + asm volatile ("noprop2 %0" : : "X" (ptr)); +} + +int *global_var; + +void +const1 (void) +{ + asm volatile ("const1 %0" : : "X" (global_var)); +} + +void +const2 (void) +{ + asm volatile ("const2 %0" : : "X" (*global_var)); +}