On Wed, May 29, 2019 at 3:21 PM Jan Hubicka <hubi...@ucw.cz> wrote: > > > > > Please also see if there are testcases that do anything meaningful > > and FAIL after instead of > > > > /* Do access-path based disambiguation. */ > > if (ref1 && ref2 > > && (handled_component_p (ref1) || handled_component_p (ref2))) > > > > doing > > > > /* Do access-path based disambiguation. */ > > if (ref1 && ref2 > > && (handled_component_p (ref1) && handled_component_p (ref2))) > > > On tramp3d we get quite few matches which are attached. If ref1 is > MEM_REF and ref2 has non-trivial access path then it seems we need: > 1) ref1 and ref2 to conflict (ref1 is a record or alias set 0) > 2) basetype2 to contain ref1 (so it conflicts too) > 3) if ref1 is a record than the access path may go into a type > contained as field of ref1 but via path not containing ref1 itself. > > I tried to construct testcase: > > truct foo {int val;} *fooptr; > struct bar {struct foo foo; int val2;} *barptr; > int test() > { > struct foo foo={0}; > barptr->val2 = 1; > *fooptr=foo; > return barptr->val2; > } > > but we do not optimize it. I.e. optimized dump has: > > test () > { > struct bar * barptr.0_1; > struct foo * fooptr.1_2; > int _6; > > <bb 2> [local count: 1073741824]: > barptr.0_1 = barptr; > barptr.0_1->val2 = 1; > fooptr.1_2 = fooptr; > MEM[(struct foo *)fooptr.1_2] = 0; > _6 = barptr.0_1->val2; > return _6; > } > > I see no reason why we should not constant propagate the return value.
Indeed a good example. Make it work and add it to the testsuite ;) I would have said get_alias_set () on the ref type should already have disambiguated 'int' (barptr->val2) from *fooptr (struct foo) but of course they conflict because foo contains 'int'. I guess it doesn't work because 'struct foo' isn't part of the other path. Here nonoverlapping_component_refs_of_decl_p would be the vehicle to use (but IIRC that would also require a common type in one of both paths). Richard. > > Honza