public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rearnsha at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/105983] Failure to optimize (b != 0) && (a >= b) as well as the same pattern with binary and
Date: Wed, 15 Jun 2022 14:20:12 +0000	[thread overview]
Message-ID: <bug-105983-4-hQuzttftpL@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-105983-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105983

--- Comment #6 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
(In reply to Richard Earnshaw from comment #5)
> (In reply to Jakub Jelinek from comment #4)
> > --- gcc/match.pd.jj	2022-06-15 12:52:04.640981511 +0200
> > +++ gcc/match.pd	2022-06-15 15:28:55.916225336 +0200
> > @@ -2379,14 +2379,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
> >  
> >  /* y == XXX_MIN || x < y --> x <= y - 1 */
> >  (simplify
> > - (bit_ior:c (eq:s @1 min_value) (lt:s @0 @1))
> > + (bit_ior:c (eq:s @1 min_value) (lt:cs @0 @1))
> >    (if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
> >         && TYPE_OVERFLOW_WRAPS (TREE_TYPE (@1)))
> >    (le @0 (minus @1 { build_int_cst (TREE_TYPE (@1), 1); }))))
> >  
> >  /* y != XXX_MIN && x >= y --> x > y - 1 */
> >  (simplify
> > - (bit_and:c (ne:s @1 min_value) (ge:s @0 @1))
> > + (bit_and:c (ne:s @1 min_value) (ge:cs @0 @1))
> >    (if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
> >         && TYPE_OVERFLOW_WRAPS (TREE_TYPE (@1)))
> >    (gt @0 (minus @1 { build_int_cst (TREE_TYPE (@1), 1); }))))
> > 
> > fixes this.
> 
> But doesn't that regress
> 
> bool f(unsigned a, unsigned b)
> {
>     return (b != 0) & (a >= b);
> }

Ignore that - I'm confusing reports.

  parent reply	other threads:[~2022-06-15 14:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-14 21:37 [Bug tree-optimization/105983] New: " gabravier at gmail dot com
2022-06-14 21:39 ` [Bug tree-optimization/105983] " pinskia at gcc dot gnu.org
2022-06-14 21:41 ` pinskia at gcc dot gnu.org
2022-06-14 21:45 ` pinskia at gcc dot gnu.org
2022-06-15 12:26 ` jakub at gcc dot gnu.org
2022-06-15 13:32 ` jakub at gcc dot gnu.org
2022-06-15 14:13 ` rearnsha at gcc dot gnu.org
2022-06-15 14:20 ` rearnsha at gcc dot gnu.org [this message]
2022-06-15 14:50 ` jakub at gcc dot gnu.org
2022-06-16 12:37 ` cvs-commit at gcc dot gnu.org
2022-06-16 12:39 ` jakub at gcc dot gnu.org

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=bug-105983-4-hQuzttftpL@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.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).