On Tue, Nov 13, 2012 at 1:50 AM, Andrew Pinski <andrew.pin...@caviumnetworks.com> wrote: > Hi, > I know we are in stage3, I thought I would send this out now for > review as I finally have it ready for consumption as I finally got > around to removing the limitation of it only working on big-endian. > This pass was originally written by Adam Nemet while he was at Cavium. > I modified it to work on little-endian and also update the code to > use the aliasing oracle and some of the new VEC interface. > > Yes I know I forgot to add documentation for the new option and for > the new pass. I will add it soon.
Note that I think the patch doesn't try to honor the C++ memory model nor arms strict volatile bitfields. My plan was to get similar results as your patch by lowering bitfield loads and stores using DECL_BIT_FIELD_REPRESENTATIVE and then let DCE/DSE and tree combine merge things. That is, you can replace a bit-field a.b.c.d with BIT_FIELD_REF <a.b.c.DECL_BIT_FIELD_REPRESENTATIVE, ...> and perform stores via read-modify-write. The DECL_BIT_FIELD_REPRESENTATIVE loads can be CSEd leaving a combining opportunity, stores will end up being redundant. The advantage is that using DECL_BIT_FIELD_REPRESENTATIVE will make you honor the memory model issues automatically - you basically perform what expand would do. Instead of generating the component-ref with the representative you can of course also lower the whole thing to a MEM_REF (if the ref does not contain variable indexes). Now, you have a pass that might be able to figure out when this lowering would be profitable - that's good, because that is what I was missing with the very simple approach of performing the above lowering from insinde gimplification. For reference I attached the BITFIELD_COMPOSE tree expression patch. Richard. > Thanks, > Andrew Pinski > > ChangeLog: > * tree-merge-const-bfstores.c: New file. > * tree-pass.h (pass_merge_const_bfstores): Add pass. > * opts.c (default_options_table): Add OPT_fmerge_const_bfstores at -O2 > and above. > * timevar.def (TV_MERGE_CONST_BFSTORES): New timevar. > * common.opt (fmerge-const-bfstores): New option. > * Makefile.in (OBJS): Add tree-merge-const-bfstores.o. > (tree-merge-const-bfstores.o): New target. > * passes.c (init_optimization_passes): Add pass_merge_const_bfstores > right after the last pass_phiopt.
bit-field-expr
Description: Binary data