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] PR combine/110867 Fix narrow comparison of memory and constant
Date: Wed, 2 Aug 2023 08:08:05 -0600	[thread overview]
Message-ID: <6a66fa72-22b2-58a5-c391-fd8f1356288e@gmail.com> (raw)
In-Reply-To: <20230802134910.2564339-2-stefansf@linux.ibm.com>



On 8/2/23 07:49, Stefan Schulze Frielinghaus via Gcc-patches wrote:
> In certain cases a constant may not fit into the mode used to perform a
> comparison.  This may be the case for sign-extended constants which are
> used during an unsigned comparison as e.g. in
> 
> (set (reg:CC 100 cc)
>      (compare:CC (mem:SI (reg/v/f:SI 115 [ a ]) [1 *a_4(D)+0 S4 A64])
>          (const_int -2147483648 [0xffffffff80000000])))
> 
> Fixed by ensuring that the constant fits into comparison mode.
> 
> Furthermore, on some targets as e.g. sparc the constant used in a
> comparison is chopped off before combine which leads to failing test
> cases (see PR 110869).  Fixed by not requiring that the source mode has
> to be DImode, and excluding sparc from the last two test cases entirely
> since there the constant cannot be further reduced.
> 
> According to PR 110867 and 110869 this patch resolves bootstrap problems
> on armv8l and sparc.  While writing this, bootstrap+regtest are still
> running on x64 and s390x.  Assuming they pass, ok for mainline?
> 
> gcc/ChangeLog:
> 
> 	PR combine/110867
> 	* combine.cc (simplify_compare_const): Try the optimization only
> 	in case the constant fits into the comparison mode.
> 
> gcc/testsuite/ChangeLog:
> 
> 	PR combine/110869
> 	* gcc.dg/cmp-mem-const-1.c: Relax mode for constant.
> 	* gcc.dg/cmp-mem-const-2.c: Relax mode for constant.
> 	* gcc.dg/cmp-mem-const-3.c: Relax mode for constant.
> 	* gcc.dg/cmp-mem-const-4.c: Relax mode for constant.
> 	* gcc.dg/cmp-mem-const-5.c: Exclude sparc since here the
> 	constant is already reduced.
> 	* gcc.dg/cmp-mem-const-6.c: Exclude sparc since here the
> 	constant is already reduced.
OK
jeff

      reply	other threads:[~2023-08-02 14:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-02 13:49 Stefan Schulze Frielinghaus
2023-08-02 14:08 ` Jeff Law [this message]

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=6a66fa72-22b2-58a5-c391-fd8f1356288e@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).