public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>,
	Manolis Tsamis <manolis.tsamis@vrull.eu>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>,
	Andrew MacLeod <amacleod@redhat.com>,
	gcc-patches@gcc.gnu.org
Subject: Re: [PATCH v1] [RFC] Improve folding for comparisons with zero in tree-ssa-forwprop.
Date: Thu, 3 Aug 2023 09:21:03 -0600	[thread overview]
Message-ID: <76e4d7a6-65af-7af3-2f33-d935cf628214@gmail.com> (raw)
In-Reply-To: <CAFiYyc3BW7Ly=8VSTm+kmZjy=09q2e-EQBbBVZvFSjr9it40Tg@mail.gmail.com>



On 8/3/23 01:04, Richard Biener wrote:
> On Wed, Aug 2, 2023 at 4:08 PM Manolis Tsamis <manolis.tsamis@vrull.eu> wrote:
>>
>> Hi all,
>>
>> I'm pinging to discuss again if we want to move this forward for GCC14.
>>
>> I did some testing again and I haven't been able to find obvious
>> regressions, including testing the code from PR86270 and PR70359 that
>> Richard mentioned.
>> I still believe that zero can be considered a special case even for
>> hardware that doesn't directly benefit in the comparison.
>> For example it happens that the testcase from the commit compiles to
>> one instruction less in x86:
>>
>> .LFB0:
>>      movl    (%rdi), %eax
>>      leal    1(%rax), %edx
>>      movl    %edx, (%rdi)
>>      testl    %eax, %eax
>>      je    .L4
>>      ret
>> .L4:
>>      jmp    g
>>
>> vs
>>
>> .LFB0:
>>      movl    (%rdi), %eax
>>      addl    $1, %eax
>>      movl    %eax, (%rdi)
>>      cmpl    $1, %eax
>>      je    .L4
>>      ret
>> .L4:
>>      xorl    %eax, %eax
>>      jmp    g
>>
>> (The xorl is not emitted  when testl is used. LLVM uses testl but also
>> does xor eax, eax :) )
>> Although this is accidental, I believe it also showcases that zero is
>> a preferential value in various ways.
>>
>> I'm running benchmarks comparing the effects of this change and I'm
>> also still looking for testcases that result in problematic
>> regressions.
>> Any feedback or other concerns about this are appreciated!
> 
> My comment from Apr 24th still holds, IMO this is something for
> instruction selection (aka the ISEL pass) or the out-of-SSA tweaks
> we do during RTL expansion (see insert_backedge_copies)
I'm still generally supportive of biasing to zero, but as Richi has 
noted the current implementation needs to be pushed further back into 
the pipeline, preferably all the way to isel or gimple->rtl expansion.

Jeff

  reply	other threads:[~2023-08-03 15:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-16 15:27 Manolis Tsamis
2023-03-16 16:41 ` Jeff Law
2023-03-16 20:32   ` Philipp Tomsich
2023-03-17  8:31 ` Richard Biener
2023-03-17 13:15   ` Philipp Tomsich
2023-03-17 14:03     ` Richard Biener
2023-03-17 20:43     ` Andrew Waterman
2023-03-17 14:12   ` Andrew MacLeod
2023-03-20 14:01   ` Manolis Tsamis
2023-03-23 23:27     ` Jeff Law
2023-04-21 21:01     ` Philipp Tomsich
2023-04-24  8:06       ` Richard Biener
2023-04-24 23:05         ` Jeff Law
2023-04-25  7:21           ` Richard Biener
2023-04-26  2:30             ` Jeff Law
2023-04-26  6:41               ` Richard Biener
2023-08-02 14:07                 ` Manolis Tsamis
2023-08-03  7:04                   ` Richard Biener
2023-08-03 15:21                     ` Jeff Law [this message]
2023-08-04  6:37                       ` Richard Biener

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=76e4d7a6-65af-7af3-2f33-d935cf628214@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=amacleod@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=manolis.tsamis@vrull.eu \
    --cc=philipp.tomsich@vrull.eu \
    --cc=richard.guenther@gmail.com \
    /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).