From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id 735A5385740B for ; Wed, 5 May 2021 12:46:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 735A5385740B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=segher@kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 145Cj5R9003214; Wed, 5 May 2021 07:45:06 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 145Cj5qW003213; Wed, 5 May 2021 07:45:05 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 5 May 2021 07:45:05 -0500 From: Segher Boessenkool To: Richard Earnshaw Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Remove CC0 Message-ID: <20210505124505.GO10366@gate.crashing.org> References: <952b5c888a98df98249088d81e954d64fad88827.1620082370.git.segher@kernel.crashing.org> <5e1b1ef9-dd0a-7dbe-458d-1df925bcecd1@foss.arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5e1b1ef9-dd0a-7dbe-458d-1df925bcecd1@foss.arm.com> User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_NUMSUBJECT, TXREP, T_SPF_HELO_PERMERROR, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 May 2021 12:46:10 -0000 Hi~ On Tue, May 04, 2021 at 04:08:22PM +0100, Richard Earnshaw wrote: > On 03/05/2021 23:55, Segher Boessenkool wrote: > >CC_STATUS_INIT is suggested in final.c to also be useful for ports that > >are not CC0, and at least arm seems to use it for something. So I am > >leaving that alone, but most targets that have it could remove it. > > A quick look through the code suggests it's being used for thumb1 code > gen to try to reproduce the traditional CC0 type behaviour of > eliminating redundant compare operations when you have sequences such as > > cmp a, b > b d1 > cmp a, b > b d2 > > The second compare operation can be eliminated. > > It might be possible to eliminate this another way by reworking the > thumb1 codegen to expose the condition codes after register allocation > has completed (much like x86 does these days), but that would be quite a > lot of work right now. I don't know if such splitting would directly > lead to the ability to remove the redundant compares - it might need a > new pass to spot them. At least on rs6000 on a simple example this is handled by fwprop1 already. Does that work for thumb1? Or maybe that uses hard regs for the condition codes and that does not work here? Example code: === void g(void); void h(void); void i(void); void f(long a, long b) { if (a < b) g(); if (a == b) h(); if (a > b) i(); } === Segher