From patchwork Thu Apr 10 16:10:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 338177 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 78F7F140090 for ; Fri, 11 Apr 2014 02:31:41 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=C/o3BJEU/UUGu516n qH2JhxLYI3tNs9kkljzNU3LPWHWwkWXXWocricv1S+avDaqvSsh6o91EtIvOby7R u0rW49ZyVDM90MjCIogdg+JqPrfMHklAw9FKnXlI6aG37ST3BFGCEzvNBhFxSc9h l19NvYtXm3SgsaUfnp8CZU+9q4= 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:date :from:to:cc:subject:message-id:reply-to:references:mime-version :content-type:in-reply-to; s=default; bh=gYtDQdDosLdrBq3MSyfQlmL YeEM=; b=i1eQfs3o64D7P0MEl9leDo0wyKZC5YRd5/2e3VkJ/Cm+GEw1/yyJRku x2AXZfIr2Zq0R3/XdAHA7jOYFECKUp7EKmKQ+PSpzEuPU5K/3+GziodCDMUUqeZY f2Y+dDwLsDwMTR4MnieitezW/beFDyF42rGkGDpL+0kjr53QcRHE= Received: (qmail 27043 invoked by alias); 10 Apr 2014 16:31:02 -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 26863 invoked by uid 89); 10 Apr 2014 16:31:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 Apr 2014 16:31:00 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3AGARsb031157 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Apr 2014 12:10:28 -0400 Received: from tucnak.zalov.cz (ovpn-116-44.ams2.redhat.com [10.36.116.44]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s3AGADrQ018130 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 10 Apr 2014 12:10:14 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.8/8.14.7) with ESMTP id s3AGA789031755; Thu, 10 Apr 2014 18:10:09 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.8/8.14.8/Submit) id s3AGA4kP031754; Thu, 10 Apr 2014 18:10:04 +0200 Date: Thu, 10 Apr 2014 18:10:04 +0200 From: Jakub Jelinek To: Zhenqiang Chen , Jeff Law Cc: "gcc-patches@gcc.gnu.org" Subject: Re: [PING] [PATCH] Fix PR rtl-optimization/pr60663 Message-ID: <20140410161004.GG1817@tucnak.redhat.com> Reply-To: Jakub Jelinek References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes On Tue, Apr 01, 2014 at 11:41:12AM +0800, Zhenqiang Chen wrote: > Ping? > > Bootstrap and no make check regression on X86-64. > > Bootstrap on ARM. In ARM regression test, some new PASS and FAIL of > debug info check for gcc.dg/guality/pr36728-1.c and > gcc.dg/guality/pr36728-2.c since register allocation result is > different with the patch. There is no real new FAIL due to the patch. > > --- a/gcc/cse.c > > +++ b/gcc/cse.c > > @@ -4280,6 +4280,19 @@ find_sets_in_insn (rtx insn, struct set **psets) > > ; > > else if (GET_CODE (SET_SRC (y)) == CALL) > > ; > > + else if (GET_CODE (SET_SRC (y)) == ASM_OPERANDS) > > + { > > + if (i + 1 < lim) > > + { > > + rtx n = XVECEXP (x, 0, i + 1); > > + /* For inline assemble with multiple outputs, we can not > > + handle the SET separately. Refer PR60663. */ > > + if (GET_CODE (n) == SET > > + && GET_CODE (SET_SRC (n)) == ASM_OPERANDS) > > + break; > > + } > > + sets[n_sets++].rtl = y; > > + } > > else > > sets[n_sets++].rtl = y; > > } This doesn't look like a correct fix. First of all, it will not handle many of the cases where we should not break the inline asm appart, e.g. if you have: int foo (void) { unsigned i; asm ("%0" : "=r" (i) : : "r5"); return i; } then it will still happily drop the clobber on the floor. But also, e.g. volatile asm or asm goto which is even stronger reason not to fiddle with it too much, isn't handled by not adding the sets in find_sets_in_insn, but rather just setting src_volatile flag. So, I'd say a better fix than this is something like following patch (untested yet, but fixes the testcase). Or, fix up the insane arm costs for ASM_OPERANDS: case ASM_OPERANDS: /* Just a guess. Cost one insn per input. */ *cost = COSTS_N_INSNS (ASM_OPERANDS_INPUT_LENGTH (x)); return true; I don't think this heuristics is even close to reality most of the time, more importantly, for no inputs, just outputs and clobbers it means *cost = 0; and that is why ARM is supposedly the only target now where CSE thinks it is worthwhile to break all inline asms without inputs appart. 2014-04-10 Jakub Jelinek PR rtl-optimization/60663 * cse.c (cse_insn): Set src_volatile on ASM_OPERANDS in PARALLEL. * gcc.target/arm/pr60663.c: New test. Jakub --- gcc/cse.c.jj 2014-03-12 10:13:41.000000000 +0100 +++ gcc/cse.c 2014-04-10 17:21:27.517330918 +0200 @@ -4642,6 +4642,13 @@ cse_insn (rtx insn) && REGNO (dest) >= FIRST_PSEUDO_REGISTER) sets[i].src_volatile = 1; + /* Also do not record result of a non-volatile inline asm with + more than one result or with clobbers, we do not want CSE to + break the inline asm apart. */ + else if (GET_CODE (src) == ASM_OPERANDS + && GET_CODE (x) == PARALLEL) + sets[i].src_volatile = 1; + #if 0 /* It is no longer clear why we used to do this, but it doesn't appear to still be needed. So let's try without it since this --- gcc/testsuite/gcc.target/arm/pr60663.c.jj 2014-04-10 17:30:04.392608591 +0200 +++ gcc/testsuite/gcc.target/arm/pr60663.c 2014-04-10 17:29:25.000000000 +0200 @@ -0,0 +1,11 @@ +/* PR rtl-optimization/60663 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=armv7-a" } */ + +int +foo (void) +{ + unsigned i, j; + asm ("%0 %1" : "=r" (i), "=r" (j)); + return i; +}