public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/113714] New: [11/12/13/14 Regression] Missed optimization for redundancy computation elimination: -(w+d-x)-x => -(w+d)
@ 2024-02-02  8:31 652023330028 at smail dot nju.edu.cn
  2024-02-04  5:32 ` [Bug tree-optimization/113714] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: 652023330028 at smail dot nju.edu.cn @ 2024-02-02  8:31 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113714
           Summary: [11/12/13/14 Regression] Missed optimization for
                    redundancy computation elimination: -(w+d-x)-x =>
                    -(w+d)
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 652023330028 at smail dot nju.edu.cn
  Target Milestone: ---

Hello, we noticed that x can be eliminated from the calculation of z in the
following code:
c-x => -(w+d-x)-x => -(w+d)

https://godbolt.org/z/MYhGTc4Pv

int x,y,z,w;
void func(int a, int b, int c, int d){
    x=a/b - y;
    c=-(w+d-x);
    z=c-x;
}

But GCC -O3 -fwrapv:
  _1 = a_7(D) / b_8(D);
  y.0_2 = y;
  _3 = _1 - y.0_2;
  x = _3;

  #Here is the part related to the calculation of z:
  w.2_4 = w;
  _20 = y.0_2 - w.2_4;
  _21 = _20 - d_11(D);
  _22 = _3 + _21;
  _6 = _22 - _1;
  z = _6;
  return;

Expected code:
GCC-10.5 -O3 -fwrapv
  _1 = a_7(D) / b_8(D);
  y.0_2 = y;
  _3 = _1 - y.0_2;
  x = _3;

  #Here is the part related to the calculation of z:
  w.2_4 = w;
  _5 = w.2_4 + d_11(D);
  _6 = -_5;
  z = _6;
  return;

Thank you very much for your time and effort! We look forward to hearing from
you.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-07 20:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-02  8:31 [Bug tree-optimization/113714] New: [11/12/13/14 Regression] Missed optimization for redundancy computation elimination: -(w+d-x)-x => -(w+d) 652023330028 at smail dot nju.edu.cn
2024-02-04  5:32 ` [Bug tree-optimization/113714] " pinskia at gcc dot gnu.org
2024-02-04  5:34 ` pinskia at gcc dot gnu.org
2024-02-11 15:20 ` pheeck at gcc dot gnu.org
2024-03-07 20:42 ` law at gcc dot gnu.org

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).