[Bug c++/86605] Suboptimal code for pointer arithmetic with 'this'

2018-07-23 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86605

Jakub Jelinek  changed:

   What|Removed |Added

   Keywords|needs-bisection |
 CC||jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek  ---
Seems this started with r245949 which was an i386 backend change.

[Bug c++/86605] Suboptimal code for pointer arithmetic with 'this'

2018-07-20 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86605

Richard Biener  changed:

   What|Removed |Added

   Keywords||needs-bisection
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-07-20
 Ever confirmed|0   |1

--- Comment #1 from Richard Biener  ---
Most certainly caused by some folding fix wrt undefined behavior.  The
difference starts to appear in CCP.  I seem to remember axing the
"trick" of stripping pointer-to-integer conversions from the lattice
so that (unsigned long)((long) + -4) + 3 might appear > 6.
Ah, so GCC 5.4 does that based on alignment considerations but it should
have nothing left after -4 + 3 ...

 ;; Function int f() (_Z1fv, funcdef_no=3, decl_uid=2101, cgraph_uid=3,
symbol_order=3)

-Folding predicate _9 > 6 to 1
-Removing basic block 3
-Merging blocks 2 and 4
 int f() ()
 {
   struct Test test;
@@ -46,13 +43,23 @@
   long int _7;
   unsigned long _8;
   unsigned long _9;
+  int iftmp.0_10;

   :
   this.1_5 = (long int) 
   _7 = this.1_5 + -4;
   _8 = (unsigned long) _7;
   _9 = _8 + 3;
-  test.i = 10;
+  if (_9 > 6)
+goto ;
+  else
+goto ;
+
+  :
+
+  :
+  # iftmp.0_10 = PHI <10(2), 20(3)>
+  test.i = iftmp.0_10;
   _3 = test.i;
   test ={v} {CLOBBER};
   return _3;