https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122058

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #46 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #45)
> (In reply to Richard Biener from comment #43)
> > (In reply to Jan Hubicka from comment #41)
> > > +  PROF_64 = [obj_type_ref] OBJ_TYPE_REF(_12;(struct
> > > ModifierStore)prephitmp_74->2B);
> > > +  if (PROF_64 ==
> > > _ZThn8_NK3icu6number4impl15LongNameHandler11getModifierENS1_6SignumENS_14Stan
> > > dardPlural4FormE.localalias)
> > > +    goto <bb 8>; [24.00%]
> > > +  else
> > > +    goto <bb 9>; [76.00%]
> > > +
> > > +  <bb 8> [local count: 229067787]:
> > > 
> > > ....
> > > 
> > > +  goto <bb 13>; [100.00%]
> > > +
> > > +  <bb 9> [local count: 725381317]:
> > > +  PROF_68 = [obj_type_ref] OBJ_TYPE_REF(_12;(struct
> > > ModifierStore)prephitmp_74->2B);
> > > 
> > > We definitely miss optimization here; PROF_68 is the same as PROF_64. I
> > > suppose FRE is confused by OBJ_TYPE_REF?
> > 
> > FRE doesn't handle OBJ_TYPE_REF in any specific way.  It's semantics
> > were never very clear to me and we seem to rely on its presence and thus
> > lowering it like RTL expansion does on its own isn't wanted.  OBJ_TYPE_REF
> > is GIMPLE_SINGLE_RHS and VN simply drops OBJ_TYPE_REF to varying.
> 
> Btw, for virtual calls we embed the OBJ_TYPE_REF as gimple_call_fn,
> and we also consider virtual tables writable?
> 
>   <bb 2> :
>   # VUSE <.MEM_5(D)>
>   _1 = a_6(D)->_vptr.A;
>   # VUSE <.MEM_5(D)>
>   _2 = *_1;
>   # .MEM_7 = VDEF <.MEM_5(D)>
>   OBJ_TYPE_REF(_2;(struct A)a_6(D)->0B) (a_6(D));
>   # VUSE <.MEM_7>
>   _3 = a_6(D)->_vptr.A;
>   # VUSE <.MEM_7>
>   _4 = *_3;
>   # .MEM_8 = VDEF <.MEM_7>
>   OBJ_TYPE_REF(_4;(struct A)a_6(D)->0B) (a_6(D));
> 
> so we do not CSE a virtual table lookup here.  I think we should see to
> improve the GIMPLE representation before improving CSE.

The vtables themselves are read-only (.rodata or .data.rel.ro for PIC), so I
guess
we could change _1 and _2 types above from something like whatever (*)
(whatever) * and whatever (*) (whatever) to their const variants (though maybe
they already are and we just don't bother printing that).  But a_6(D)->_vptr.A
can change (though it does change only in constructors or destructors, so I bet
it can't change in between the calls above, if it was a ctor or dtor, we'd see
the change in the IL, ctors are never virtual and while dtors can be, I think
it isn't valid to call a dtor this way and then call it again and random
methods on a class shouldn't destruct the class under it (though, perhaps I'm
wrong).

Anyway, per the above discussions downgrading this to P2 as it is likely latent
for several releases.

Reply via email to