On Mon, 9 May 2016, Marc Glisse wrote: > On Mon, 9 May 2016, Richard Biener wrote: > > > The following patch implements CSEing of "subreg" reads from memory > > like (from the testcase in the PR) > > > > union U { int i[16]; char c; }; > > > > char foo(int i) > > { > > union U u; > > u.i[0] = i; > > return u.c; > > } > > > > CSEing u.c as (char)i and thus removing u during GIMPLE optimizations. > > > > The patch always goes via generating BIT_FIELD_REFs and letting them > > be simplified via the match-and-simplify machinery. This means it > > replaces handling of complex component and vector extracts we've been > > able to do before. > > > > I didn't restrict the kind of BIT_FIELD_REFs much apart from requiring > > byte-size accesses. I did inspect code generated on powerpc (big-endian) > > for the testcase though (also to verify any endianess issues) and didn't > > spot anything wrong (even for non-lowpart "subregs"). > > I expect this will also fix https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28367 > (reading an element from a vector through a union)?
Yes. Will add the testcase and adjust the ChangeLog entry. Thanks for the heads-up. Richard.