public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "amacleod at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/113301] [12/13/14 Regression] Missed optimization: (1/(x+1))/2 => 0 since gcc-12
Date: Wed, 10 Jan 2024 20:37:14 +0000	[thread overview]
Message-ID: <bug-113301-4-yX5zBjQDPx@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113301-4@http.gcc.gnu.org/bugzilla/>

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

Andrew Macleod <amacleod at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amacleod at redhat dot com

--- Comment #5 from Andrew Macleod <amacleod at redhat dot com> ---
(In reply to Jakub Jelinek from comment #4)
> Even then, I wonder why ranger doesn't figure this out.
> (x+1u) <= 2 ? x : 0
> must have a range [-1, 1] and [-1, 1] / [2, 2] range should be [0, 0], no?

its because there is no branch which is what drives ranger. At this point, we
aren't quite smart enough to completely evaluate the 2 operands of a
conditional as if they were actual  branches.
ie
    _1 = x_4(D) + 1;
    _10 = (unsigned int) x_4(D);
    _6 = _10 + 2;
    _7 = _6 <= 2;
    _2 = _7 ? _1 : 0;

if that were:
  if (_6 <= 2)
    _2 = _1
we'd recalculate _1 with the condition being (_6 <= 2) and we come upwith [-1,
1] for _1 instead of varying.

I'll have to look at whats involved in enhancing the fold code to invoke GORI
to reevaluate _1 if _7 is [1,1].   in theory is not too difficult... :-)

  parent reply	other threads:[~2024-01-10 20:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-10  5:24 [Bug tree-optimization/113301] New: " 652023330028 at smail dot nju.edu.cn
2024-01-10  5:50 ` [Bug tree-optimization/113301] " pinskia at gcc dot gnu.org
2024-01-10  7:49 ` rguenth at gcc dot gnu.org
2024-01-10  9:03 ` jakub at gcc dot gnu.org
2024-01-10 10:16 ` pinskia at gcc dot gnu.org
2024-01-10 17:11 ` jakub at gcc dot gnu.org
2024-01-10 20:37 ` amacleod at redhat dot com [this message]
2024-01-10 22:12 ` amacleod at redhat dot com
2024-01-10 22:25 ` pinskia at gcc dot gnu.org
2024-01-11  4:24 ` pinskia at gcc dot gnu.org
2024-01-11 18:01 ` cvs-commit at gcc dot gnu.org
2024-01-11 18:03 ` pinskia 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-113301-4-yX5zBjQDPx@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).