On Tue, May 10, 2016 at 10:18:59AM +0200, Richard Biener wrote: > There are two options - not apply this folding if it doesn't preserve > TBAA behavior (first patch) or preserve TBAA behavior by wrapping > the base into a MEM_REF (which also requires fixing > reference_alias_ptr_type, sth which we need to do anyway). > See the two patches below. > > Incidentially the folding (which I still consider premature) prevents > CSE on the GIMPLE level as well: > > <bb 2>: > MEM[(struct &)this_2(D)] ={v} {CLOBBER}; > _4 = &this_2(D)->m_str; > MEM[(struct &)this_2(D)] ={v} {CLOBBER}; > MEM[(struct short_t &)this_2(D)].h.is_short = 1; > MEM[(struct short_t &)this_2(D)].h.length = 0; > MEM[(struct short_t &)this_2(D)].data[0] = 0; > _19 = BIT_FIELD_REF <MEM[(void *)this_2(D)], 8, 0>; > _20 = _19 & 1; > if (_20 != 0) > > Here we can't CSE the is_short access and optimize the compare. > So on trunk I am thinking of at least removing the compare > against constant case. [I've removed the whole code twice in > GCC history and it always got installed back ...] > > Bootstrap and regtest of both patches running on x86_64-unknown-linux-gnu. > > Any preference for GCC 6?
I think I prefer the second patch for the branch. Jakub