------- Comment #14 from rguenther at suse dot de  2010-09-16 12:51 -------
Subject: Re:  Missed devirtualization

On Thu, 16 Sep 2010, hubicka at ucw dot cz wrote:

> ------- Comment #13 from hubicka at ucw dot cz  2010-09-16 12:48 -------
> Subject: Re:  Missed devirtualization
> 
> > I'm lost in this PR - for what testcase what statement needs folding
> > (and what pending patches do I need to apply to see that)?
> PR is tracking missed optimization in the testcase in comment 0.
> 
> There are two issues
> 
> 
> 
> 1) OBJ_TYPE_REF folding should handle it.  For that we seem to need to
> evern call fold on 
>   OBJ_TYPE_REF(D.2210_2;&d.D.2108->0) (&d.D.2108);
> this you can see on mainline
> 
> 2) generic folding should work it out the hard way. I.e. for:
>   MEM[(struct B *)&d]._vptr.B = &_ZTV1B[2];
>   d.D.2108._vptr.B = &_ZTV1D[2];
>   D.2210_2 = _ZTV1D[2];
>   OBJ_TYPE_REF(D.2210_2;&d.D.2108->0) (&d.D.2108);
> there is nothing that prevents us to resolve _ZTV1D[2] into pointer to Run (by
> looking into initializer of vtable variable) and then take OBJ_TYPE_REF away
> since it is pointless when first operand is known function.
> 
> With patch http://gcc.gnu.org/ml/gcc-patches/2010-09/msg01190.html we closer 
> in
> a way that .vpr1 dump has:
>   MEM[(struct B *)&d]._vptr.B = &_ZTV1B[2];
>   d.D.2078._vptr.B = &_ZTV1D[2];
>   D.2179_1 = &_ZTV1D[2];
>   D.2180_2 = (int (*__vtbl_ptr_type) (void)) Run;
>   OBJ_TYPE_REF(D.2180_2;&d.D.2078->0) (&d.D.2078);
> 
> Somewhere I have patch that adds OBJ_TYPE_REF folding into CCP (so when first
> argument is function pointer, we just fold into direct call). I will update it
> and submit after http://gcc.gnu.org/ml/gcc-patches/2010-09/msg01190.html
> is resolved.  Then still there is problem that resolution comes late
> since we need FRE to fold
>  d.D.2078._vptr.B = &_ZTV1D[2];
>   D.2179_1 =  d.D.2078._vptr.B
> and FRE is not run early (and we should devirutalize everything early
> to get inlining)
> 
> 
> 
> 1) is priority IMO (at moment we make amazingly little devirtualization at
> Mozilla, about 20 calls).
> 2) is just side effect of my attempt to get folding working that I run into
> while looking into kernel poor man C vtables (and ours targhooks).

1) should be fixed by using fold_stmt in gimplify_call instead of
just fold_call_expr.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45605

Reply via email to