This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/86605] Suboptimal code for pointer arithmetic with 'this'
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 20 Jul 2018 11:00:21 +0000
- Subject: [Bug c++/86605] Suboptimal code for pointer arithmetic with 'this'
- Auto-submitted: auto-generated
- References: <bug-86605-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86605
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |needs-bisection
Status|UNCONFIRMED |NEW
Last reconfirmed| |2018-07-20
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
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)&test + -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;
<bb 2>:
this.1_5 = (long int) &test;
_7 = this.1_5 + -4;
_8 = (unsigned long) _7;
_9 = _8 + 3;
- test.i = 10;
+ if (_9 > 6)
+ goto <bb 4>;
+ else
+ goto <bb 3>;
+
+ <bb 3>:
+
+ <bb 4>:
+ # iftmp.0_10 = PHI <10(2), 20(3)>
+ test.i = iftmp.0_10;
_3 = test.i;
test ={v} {CLOBBER};
return _3;