[Bug tree-optimization/114511] [11/12/13/14 Regression] Missed optimization: x = -y; x = c + x + y; ==> x=c;

2024-04-05 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114511

--- Comment #2 from Richard Biener  ---
Confirmed.

  _3 = _1 + _2;
  y = _3;
  _18 = b_9(D) + c_12(D);
  _19 = _18 - a_8(D);
  _20 = _3 + _19;
  _6 = _20 - _1;

re-association doesn't associate the def of _3 because it has multiple uses
and there's no special handling of

 ((_1 + _2) + _19) - _1

what makes this work for -fno-wrapv is the fre1 difference (+ is -fwrapv)

 Replaced y with _3 in all uses of y.0_4 = y;
+Matching expression match.pd:2030, gimple-match-6.cc:54
+Applying pattern match.pd:2057, gimple-match-2.cc:4362
+Applying pattern match.pd:2048, gimple-match-6.cc:2758
+gimple_simplified to _18 = b_12(D) - a_11(D);
+_5 = _18 - _1;
 Replaced x with _5 in all uses of x.1_6 = x;
-Applying pattern match.pd:4682, gimple-match-6.cc:4679
-Applying pattern match.pd:3432, gimple-match-7.cc:531
-gimple_simplified to _18 = c_16(D) - _3;
-_7 = _18;
 Replaced y with _3 in all uses of y.2_8 = y;
-Applying pattern match.pd:4682, gimple-match-7.cc:4394
-Applying pattern match.pd:3494, gimple-match-6.cc:508
-gimple_simplified to _9 = c_16(D);
 Removing dead stmt y.2_8 = y;
 Removing dead stmt x.1_6 = x;
 Removing dead stmt y.0_4 = y;
@@ -77,12 +77,12 @@
   _2 = a_11(D) - b_12(D);
   _3 = _1 + _2;
   y = _3;
-  _5 = -_3;
+  _18 = b_12(D) - a_11(D);
+  _5 = _18 - _1;
   x = _5;
-  _18 = c_16(D) - _3;
-  _7 = _18;
-  _9 = c_16(D);
-  x = c_16(D);
+  _7 = _5 + c_16(D);
+  _9 = _3 + _7;
+  x = _9;
   return;

 }

[Bug tree-optimization/114511] [11/12/13/14 Regression] Missed optimization: x = -y; x = c + x + y; ==> x=c;

2024-04-04 Thread law at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114511

Jeffrey A. Law  changed:

   What|Removed |Added

 CC||law at gcc dot gnu.org
   Priority|P3  |P2

[Bug tree-optimization/114511] [11/12/13/14 Regression] Missed optimization: x = -y; x = c + x + y; ==> x=c;

2024-04-02 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114511

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|--- |11.5

[Bug tree-optimization/114511] [11/12/13/14 Regression] Missed optimization: x = -y; x = c + x + y; ==> x=c;

2024-03-28 Thread xry111 at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114511

Xi Ruoyao  changed:

   What|Removed |Added

 Ever confirmed|0   |1
   Keywords||needs-bisection
  Known to work||7.1.0
  Known to fail||8.1.0
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2024-03-28
 CC||xry111 at gcc dot gnu.org
Summary|[Regression] Missed |[11/12/13/14 Regression]
   |optimization: x = -y; x = c |Missed optimization: x =
   |+ x + y; ==> x=c;   |-y; x = c + x + y; ==> x=c;

--- Comment #1 from Xi Ruoyao  ---
Confirmed.