On Thu, Nov 12, 2020 at 10:49:40AM +0100, Jan Hubicka wrote:
> > > +           if (!operand_equal_p (DECL_FIELD_OFFSET (field0),
> > > +                                 DECL_FIELD_OFFSET (field1),
> > > +                                 flags & ~OEP_ADDRESS_OF)
> > > +               || !operand_equal_p (DECL_FIELD_BIT_OFFSET (field0),
> > > +                                    DECL_FIELD_BIT_OFFSET (field1),
> > > +                                    flags & ~OEP_ADDRESS_OF))
> > 
> > If it is an address, why do you need to handle
> > DECL_BIT_FIELD_REPRESENTATIVE?  Taking address of a bit-field is not 
> > allowed.
> > Perhaps just return false if the fields are bit-fields (or assert they
> > aren't), and just compare DECL_FIELD*OFFSET of the fields themselves?
> 
> I took the code from nonoverlapping_component_refs_p_1, however in
> compare_ao_refs i call compare_operands on OEP_ADDRESS for memory
> operands, so it would be useful there.  I think it makes sense in that
> context - in order to match memory acesses for equivalence we want to
> first compare that they access same memory location...

If OEP_ADDRESS is used also on non-addressable stuff, just to compare
that two COMPONENT_REFs access the same memory, then just comparing
DECL_BIT_FIELD_REPRESENTATIVE is not sufficient, you could have:
struct S { int c; int a : 7, b : 1; };
struct T { int c; int a : 7, b : 1; };
and compare s->a vs. t->b with OEP_ADDRESS and the offsets of their
DECL_BIT_FIELD_REPRESENATIVE is the same, yet we don't want to say
the two bit-fields are the same.

        Jakub

Reply via email to