Re: Compare field offsets in fold_const when checking addresses

2020-11-12 Thread Richard Biener
On Thu, 12 Nov 2020, Jan Hubicka wrote: > > On Thu, 12 Nov 2020, Jan Hubicka wrote: > > > > > Hi, > > > this is updated patch I am re-testing and plan to commit if it suceeds. > > > > > > * fold-const.c (operand_compare::operand_equal_p): Compare > > > offsets of fields in component_refs whe

Re: Compare field offsets in fold_const when checking addresses

2020-11-12 Thread Jan Hubicka
> On Thu, 12 Nov 2020, Jan Hubicka wrote: > > > Hi, > > this is updated patch I am re-testing and plan to commit if it suceeds. > > > > * fold-const.c (operand_compare::operand_equal_p): Compare > > offsets of fields in component_refs when comparing addresses. > > (operand_compare::ha

Re: Compare field offsets in fold_const when checking addresses

2020-11-12 Thread Richard Biener
On Thu, 12 Nov 2020, Jan Hubicka wrote: > Hi, > this is updated patch I am re-testing and plan to commit if it suceeds. > > * fold-const.c (operand_compare::operand_equal_p): Compare > offsets of fields in component_refs when comparing addresses. > (operand_compare::hash_operand

Re: Compare field offsets in fold_const when checking addresses

2020-11-12 Thread Jan Hubicka
Hi, this is updated patch I am re-testing and plan to commit if it suceeds. * fold-const.c (operand_compare::operand_equal_p): Compare offsets of fields in component_refs when comparing addresses. (operand_compare::hash_operand): Likewise. diff --git a/gcc/fold-const.c b/gc

Re: Compare field offsets in fold_const when checking addresses

2020-11-12 Thread Jan Hubicka
> > * fold-const.c (operand_compare::operand_equal_p): When comparing > > addresses > > look info field offsets for COMPONENT_REFs. > > (operand_compare::hash_operand): Likewise. > > diff --git a/gcc/fold-const.c b/gcc/fold-const.c > > index c47557daeba..a4e8cccb1b7 100644 > > --- a/gc

Re: Compare field offsets in fold_const when checking addresses

2020-11-12 Thread Richard Biener
On Thu, 12 Nov 2020, Jan Hubicka wrote: > Hi, > with ipa-icf we often run into problem that operand_equal_p does not > match ADDR_EXPR that take address of fields from two different instances > of same class (at ideantical offsets). Similar problem can also happen > for record types with LTO if t

Re: Compare field offsets in fold_const when checking addresses

2020-11-12 Thread Jan Hubicka
> > How is that different from: > > struct S { long long d; int e; }; > > struct T { long long d; long long e; }; > > s->e vs. t->e ? > > One thing is comparison of the address (as it is comparing > > DECL_FIELD_BIT_OFFSET too, it is essentially bit-address), and another thing > > (unlrelated to OE

Re: Compare field offsets in fold_const when checking addresses

2020-11-12 Thread Jan Hubicka
> On Thu, Nov 12, 2020 at 11:39:07AM +0100, Jan Hubicka wrote: > > > On Thu, Nov 12, 2020 at 11:29:21AM +0100, Jan Hubicka wrote: > > > > > If OEP_ADDRESS is used also on non-addressable stuff, just to compare > > > > > that two COMPONENT_REFs access the same memory, then just comparing > > > > > D

Re: Compare field offsets in fold_const when checking addresses

2020-11-12 Thread Jakub Jelinek via Gcc-patches
On Thu, Nov 12, 2020 at 11:39:07AM +0100, Jan Hubicka wrote: > > On Thu, Nov 12, 2020 at 11:29:21AM +0100, Jan Hubicka wrote: > > > > 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_FI

Re: Compare field offsets in fold_const when checking addresses

2020-11-12 Thread Jan Hubicka
> On Thu, Nov 12, 2020 at 11:29:21AM +0100, Jan Hubicka wrote: > > > 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

Re: Compare field offsets in fold_const when checking addresses

2020-11-12 Thread Jakub Jelinek via Gcc-patches
On Thu, Nov 12, 2020 at 11:29:21AM +0100, Jan Hubicka wrote: > > 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; i

Re: Compare field offsets in fold_const when checking addresses

2020-11-12 Thread Jan Hubicka
> 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) > > > > +

Re: Compare field offsets in fold_const when checking addresses

2020-11-12 Thread Jakub Jelinek via Gcc-patches
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_equ

Re: Compare field offsets in fold_const when checking addresses

2020-11-12 Thread Jan Hubicka
> > + if (!operand_equal_p (DECL_FIELD_OFFSET (field0), > > + DECL_FIELD_OFFSET (field1), > > + flags & ~OEP_ADDRESS_OF) > > + || !operand_equal_p (DECL_FIELD_BIT_OFFSET (field0), > > +

Re: Compare field offsets in fold_const when checking addresses

2020-11-12 Thread Jakub Jelinek via Gcc-patches
On Thu, Nov 12, 2020 at 10:36:28AM +0100, Jan Hubicka wrote: > * fold-const.c (operand_compare::operand_equal_p): When comparing > addresses > look info field offsets for COMPONENT_REFs. > (operand_compare::hash_operand): Likewise. > diff --git a/gcc/fold-const.c b/gcc/fold-const