public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>,
	gcc-patches@gcc.gnu.org
Subject: Re: [PATCH v2] combine: Narrow comparison of memory and constant
Date: Mon, 31 Jul 2023 07:59:19 -0600	[thread overview]
Message-ID: <d06fc2ff-f006-a05b-fd18-d9050f66485d@gmail.com> (raw)
In-Reply-To: <20230619142356.345159-1-stefansf@linux.ibm.com>



On 6/19/23 08:23, Stefan Schulze Frielinghaus via Gcc-patches wrote:
> Comparisons between memory and constants might be done in a smaller mode
> resulting in smaller constants which might finally end up as immediates
> instead of in the literal pool.
> 
> For example, on s390x a non-symmetric comparison like
>    x <= 0x3fffffffffffffff
> results in the constant being spilled to the literal pool and an 8 byte
> memory comparison is emitted.  Ideally, an equivalent comparison
>    x0 <= 0x3f
> where x0 is the most significant byte of x, is emitted where the
> constant is smaller and more likely to materialize as an immediate.
> 
> Similarly, comparisons of the form
>    x >= 0x4000000000000000
> can be shortened into x0 >= 0x40.
> 
> Bootstrapped and regtested on s390x, x64, aarch64, and powerpc64le.
> Note, the new tests show that for the mentioned little-endian targets
> the optimization does not materialize since either the costs of the new
> instructions are higher or they do not match.  Still ok for mainline?
> 
> gcc/ChangeLog:
> 
> 	* combine.cc (simplify_compare_const): Narrow comparison of
> 	memory and constant.
> 	(try_combine): Adapt new function signature.
> 	(simplify_comparison): Adapt new function signature.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* gcc.dg/cmp-mem-const-1.c: New test.
> 	* gcc.dg/cmp-mem-const-2.c: New test.
> 	* gcc.dg/cmp-mem-const-3.c: New test.
> 	* gcc.dg/cmp-mem-const-4.c: New test.
> 	* gcc.dg/cmp-mem-const-5.c: New test.
> 	* gcc.dg/cmp-mem-const-6.c: New test.
> 	* gcc.target/s390/cmp-mem-const-1.c: New test.
Sorry.  I'd looked at this a while back, wanted to take another looksie 
and totally forgot about it.

OK for the trunk.  Thanks for your patience.

jeff


  parent reply	other threads:[~2023-07-31 13:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12  7:57 [PATCH] " Stefan Schulze Frielinghaus
2023-06-12 21:29 ` Jeff Law
2023-06-19 14:19   ` Stefan Schulze Frielinghaus
2023-06-19 14:23     ` [PATCH v2] " Stefan Schulze Frielinghaus
2023-07-31 13:26       ` Stefan Schulze Frielinghaus
2023-07-31 13:59       ` Jeff Law [this message]
2023-07-31 21:43       ` Prathamesh Kulkarni
2023-07-31 21:46         ` Prathamesh Kulkarni
2023-07-31 23:50         ` Jeff Law
2023-08-01  8:22           ` Prathamesh Kulkarni
2023-08-01  9:36             ` Stefan Schulze Frielinghaus

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=d06fc2ff-f006-a05b-fd18-d9050f66485d@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=stefansf@linux.ibm.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).