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 74010385380D for ; Thu, 27 May 2021 22:20:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 74010385380D 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 14RMJg5p015198; Thu, 27 May 2021 17:19:42 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 14RMJfXR015197; Thu, 27 May 2021 17:19:41 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Thu, 27 May 2021 17:19:40 -0500 From: Segher Boessenkool To: "Koning, Paul" Cc: Richard Earnshaw , GCC Patches Subject: Re: [PATCH] Remove CC0 Message-ID: <20210527221940.GA3085@gate.crashing.org> References: <952b5c888a98df98249088d81e954d64fad88827.1620082370.git.segher@kernel.crashing.org> <5e1b1ef9-dd0a-7dbe-458d-1df925bcecd1@foss.arm.com> <20210505124505.GO10366@gate.crashing.org> <6CECF8F7-5271-4C77-955A-9915EB6075B7@dell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6CECF8F7-5271-4C77-955A-9915EB6075B7@dell.com> User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-6.1 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: Thu, 27 May 2021 22:20:53 -0000 Hi! Whoops, I forgot to reply to this... On Wed, May 05, 2021 at 06:25:49PM +0000, Koning, Paul wrote: > > 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(); > > } > > FWIW, that also works on pdp11, so it seems the general mechanism is in place and working. Well, with one oddity, an unnecessary third conditional branch: > > _f: > mov 02(sp),r1 > mov 04(sp),r0 > cmp r1,r0 > blt L_7 > beq L_4 > bgt L_5 > rts pc > L_5: > jsr pc,_i > rts pc > L_4: > jsr pc,_h > rts pc > L_7: > jsr pc,_g > rts pc We have that on PowerPC as well (-m32 because it is shorter code with fewer distractions): f: cmpw 0,3,4 blt 0,.L9 beq 0,.L3 blelr 0 b i .p2align 4,,15 .L3: b h .p2align 4,,15 .L9: b g The "blelr" (branch to LR if less than or equal) can never be taken. This is there in the Gimple already: === void f (long int a, long int b) { ;; basic block 2, loop depth 0 ;; pred: ENTRY if (a_4(D) < b_5(D)) goto ; [33.00%] else goto ; [67.00%] ;; succ: 3 ;; 4 ;; basic block 3, loop depth 0 ;; pred: 2 g (); [tail call] goto ; [100.00%] ;; succ: 8 ;; basic block 4, loop depth 0 ;; pred: 2 if (a_4(D) == b_5(D)) goto ; [30.21%] else goto ; [69.79%] ;; succ: 6 ;; 5 ;; basic block 5, loop depth 0 ;; pred: 4 if (a_4(D) > b_5(D)) goto ; [70.57%] else goto ; [29.43%] ;; succ: 7 ;; 8 ;; basic block 6, loop depth 0 ;; pred: 4 h (); [tail call] goto ; [100.00%] ;; succ: 8 ;; basic block 7, loop depth 0 ;; pred: 5 i (); [tail call] ;; succ: 8 ;; basic block 8, loop depth 0 ;; pred: 5 ;; 7 ;; 6 ;; 3 return; ;; succ: EXIT } === So, it also exists in the RTL -- and it isn't optimised away later. That would be quite hard to do in fact, and if it is handled in Gimple all will be fine, and it should be much easier to do in Gimple. Can you open a PR please? Segher