public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Koning, Paul" <Paul.Koning@dell.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: Richard Earnshaw <Richard.Earnshaw@foss.arm.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Remove CC0
Date: Wed, 5 May 2021 18:25:49 +0000	[thread overview]
Message-ID: <6CECF8F7-5271-4C77-955A-9915EB6075B7@dell.com> (raw)
In-Reply-To: <20210505124505.GO10366@gate.crashing.org>



> On May 5, 2021, at 8:45 AM, Segher Boessenkool <segher@kernel.crashing.org> wrote:
> 
> 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<cond1> d1
>> cmp a, b
>> b<cond2> 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();
> }

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


  reply	other threads:[~2021-05-05 18:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-03 22:55 Segher Boessenkool
2021-05-04  8:44 ` Richard Biener
2021-05-04 13:45   ` Segher Boessenkool
2021-05-04 15:08 ` Richard Earnshaw
2021-05-04 16:22   ` Eric Botcazou
2021-05-04 16:24     ` Richard Earnshaw
2021-05-05 12:45   ` Segher Boessenkool
2021-05-05 18:25     ` Koning, Paul [this message]
2021-05-27 22:19       ` Segher Boessenkool
2021-05-27 19:58 ` H.J. Lu
2021-05-27 22:28   ` Segher Boessenkool
2021-05-28  4:20     ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6CECF8F7-5271-4C77-955A-9915EB6075B7@dell.com \
    --to=paul.koning@dell.com \
    --cc=Richard.Earnshaw@foss.arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=segher@kernel.crashing.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).