From patchwork Thu Aug 15 19:46:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 1147820 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-507085-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="GnfPvZ8J"; 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 468cRN0kSBz9s7T for ; Fri, 16 Aug 2019 05:47:09 +1000 (AEST) 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:subject:date:message-id:references:in-reply-to:content-type :mime-version; q=dns; s=default; b=A5x2gHaIIAZZ2OhMqFQgQN5+sj0b1 4DulfRenyl5jqKVCR0oMECbSyjFIk7sQmxyy/OzWJzTzG2DHHIUwvz5Wr2drvJ2F /6rg9xbhlokt4psVM6H3Ghemp1HgFEO+AgQFepx3kqDfzKGBSXwHBUuis877h2gg 2KnXsjMUyPyXiI= 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:subject:date:message-id:references:in-reply-to:content-type :mime-version; s=default; bh=WJYRQUAjJmLM1R3Zm6LhjSx+uS4=; b=Gnf PvZ8JbKo87bF6PmeUfqW3gIWQBzO6sjs8iWVK1Kmz1CVGpw2gWJM67oTThTr70FD cw7bncIKy60RlcMw9Z9KvoEF2ZPejd2tpQYF2P6g9QZQWAnf9F2Ee9ZepipljdhG /R4T9d+e8WOxVtgnAAMLMDgXcToTT7tQJluywGT4= Received: (qmail 104112 invoked by alias); 15 Aug 2019 19:47: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 104104 invoked by uid 89); 15 Aug 2019 19:47:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=audit, continuing, pseudos, H*c:HHH X-HELO: EUR03-AM5-obe.outbound.protection.outlook.com Received: from mail-oln040092070031.outbound.protection.outlook.com (HELO EUR03-AM5-obe.outbound.protection.outlook.com) (40.92.70.31) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 15 Aug 2019 19:47:00 +0000 Received: from VE1EUR03FT021.eop-EUR03.prod.protection.outlook.com (10.152.18.53) by VE1EUR03HT079.eop-EUR03.prod.protection.outlook.com (10.152.19.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2052.18; Thu, 15 Aug 2019 19:46:57 +0000 Received: from AM6PR10MB2566.EURPRD10.PROD.OUTLOOK.COM (10.152.18.59) by VE1EUR03FT021.mail.protection.outlook.com (10.152.18.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2178.16 via Frontend Transport; Thu, 15 Aug 2019 19:46:57 +0000 Received: from AM6PR10MB2566.EURPRD10.PROD.OUTLOOK.COM ([fe80::4056:d9d8:9ce5:1976]) by AM6PR10MB2566.EURPRD10.PROD.OUTLOOK.COM ([fe80::4056:d9d8:9ce5:1976%4]) with mapi id 15.20.2157.022; Thu, 15 Aug 2019 19:46:57 +0000 From: Bernd Edlinger To: Vladimir Makarov , "gcc-patches@gcc.gnu.org" Subject: [PATCH] [LRA] Fix wrong-code PR 91109 take 2 Date: Thu, 15 Aug 2019 19:46:57 +0000 Message-ID: References: <6a79fb83-d6d5-63fa-c16e-ccea9d2f93ca@redhat.com> In-Reply-To: <6a79fb83-d6d5-63fa-c16e-ccea9d2f93ca@redhat.com> x-microsoft-original-message-id: MIME-Version: 1.0 Hi, as discussed in the PR 91109 audit trail, my previous patch missed a case where no spilling is necessary, but the re-materialized instruction has now scratch regs without a hard register assignment. And thus the LRA pass falls out of the loop pre-maturely. Fixed by checking for scratch regs with no assignment and continuing the loop in that case. Boot-strapped and reg-tested on x86_64-pc-linux-gnu and arm-linux-gnueabihf. Is it OK for trunk? Thanks Bernd. 2019-08-12 Bernd Edlinger PR tree-optimization/91109 * lra-int.h (lra_need_for_scratch_reg_p): Declare. * lra.c (lra): Use lra_need_for_scratch_reg_p. * lra-spills.c (lra_need_for_scratch_reg_p): New function. Index: gcc/lra-int.h =================================================================== --- gcc/lra-int.h (revision 274168) +++ gcc/lra-int.h (working copy) @@ -396,6 +396,7 @@ extern bool lra_coalesce (void); /* lra-spills.c: */ +extern bool lra_need_for_scratch_reg_p (void); extern bool lra_need_for_spills_p (void); extern void lra_spill (void); extern void lra_final_code_change (void); Index: gcc/lra-spills.c =================================================================== --- gcc/lra-spills.c (revision 274168) +++ gcc/lra-spills.c (working copy) @@ -549,6 +549,19 @@ spill_pseudos (void) } } +/* Return true if we need scratch reg assignments. */ +bool +lra_need_for_scratch_reg_p (void) +{ + int i; max_regno = max_reg_num (); + + for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++) + if (lra_reg_info[i].nrefs != 0 && lra_get_regno_hard_regno (i) < 0 + && lra_former_scratch_p (i)) + return true; + return false; +} + /* Return true if we need to change some pseudos into memory. */ bool lra_need_for_spills_p (void) Index: gcc/lra.c =================================================================== --- gcc/lra.c (revision 274168) +++ gcc/lra.c (working copy) @@ -2567,7 +2567,11 @@ lra (FILE *f) lra_create_live_ranges (lra_reg_spill_p, true); live_p = true; if (! lra_need_for_spills_p ()) - break; + { + if (lra_need_for_scratch_reg_p ()) + continue; + break; + } } lra_spill (); /* Assignment of stack slots changes elimination offsets for