On Wed, 3 Sept 2025 at 17:41, Richard Biener <[email protected]> wrote: > > > > > Am 03.09.2025 um 15:51 schrieb Jakub Jelinek <[email protected]>: > > > > On Wed, Sep 03, 2025 at 03:27:08PM +0200, Richard Biener wrote: > >> When inside a method then we know the this pointer points to > >> an object of at least the size of the methods base type. We > >> can use this to compute more references as not trapping and > >> enable invariant motion and in turn vectorization as for a > >> slightly modified version of the testcase in the PR. > > > > I'd be worried about C++23 deducing this, but e.g. > > struct S; > > extern S t; > > struct S > > { > > void foo (this S *p, int x); > > int s; > > }; > > void S::foo (this S *p, int x) > > { > > p->s += x; > > p = &t; > > p->s += x; > > } > > Huh, you can assign to the ‚this‘ parameter?
This is a normal function parameter of a static member function, not the implicit 'this' pointer which is present in non-static member functions (a.k.a. methods). The pointer named 'p' is just a normal variable, you can assign to it unless it's declared const in the function parameter-list. > I’ve read it can be a non-pointer. That's true for 'this' but this is not 'this' > But assigning to it makes the non-SSA match broken. What’s the use of such > assignment? > Is p = nullptr valid? Or delete p;? Yes (and 'delete this' is also valid, as long as you don't dereference that pointer again afterwards, so it generally needs to be the last thing you do in a member function before returning). > > But yes, I’ll add a testcase that would break when these become METHOD_TYPE. > > Richard > > > uses FUNCTION_TYPE rather than METHOD_TYPE. > > > > Jakub > > >
