public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/113265] [Regression] Missed optimization for redundancy computation elimination may be due to constant propagation about 0 too late
Date: Tue, 09 Jan 2024 08:06:12 +0000	[thread overview]
Message-ID: <bug-113265-4-qDDRgvzJCs@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113265-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
           Keywords|                            |missed-optimization
   Last reconfirmed|                            |2024-01-09

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
We're somehow expanding -b as x - b.  That's done by forwprop seeing

  <bb 2> :
  x.0_1 = x;
  a_8 = b_7(D) - x.0_1;
  y = 0;
  y.1_2 = y;
  _3 = a_8 + y.1_2;
  _4 = -a_8;
  _5 = _3 / _4;
  z = _5;

this transform is done irrespectively of whether the non-negated expression
is still used (its a 1:1 replacement, though unary to binary).  We're
thn missing folding of

  a_8 = b_7(D) - x.0_1;
  _4 = x.0_1 - b_7(D);
  _5 = a_8 / _4;

failing to realize this is a_8 / -a_8.

Reduced testcase which isn't optimized by GCC 7 either:

int z;
void func(int a, int b){
    z=(a-b)/-(a-b);
}
void func1(int a, int b){
    z=(a-b)/(b-a);
}

  reply	other threads:[~2024-01-09  8:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-08  8:25 [Bug tree-optimization/113265] New: " 652023330028 at smail dot nju.edu.cn
2024-01-09  8:06 ` rguenth at gcc dot gnu.org [this message]
2024-01-09  8:16 ` [Bug tree-optimization/113265] " rguenth at gcc dot gnu.org
2024-01-09  8:43 ` pinskia at gcc dot gnu.org
2024-01-09 22:55 ` [Bug tree-optimization/113265] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
2024-01-09 23:01 ` pinskia at gcc dot gnu.org
2024-03-07 20:52 ` law at gcc dot gnu.org
2024-05-26  5:43 ` [Bug tree-optimization/113265] [11/12/13/14/15 " pinskia at gcc dot gnu.org
2024-05-26  5:44 ` 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-113265-4-qDDRgvzJCs@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).