https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93582
--- Comment #20 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 47814 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47814&action=edit gcc10-pr93582-wip.patch WIP patch, so far only the store covering all the bits (the reconstruction from pieces could be done later) for non-byte aligned positions or sizes and only done for little endian (of course will handle big endian next); the last hunk is the workaround for the premature optimization, so if we nuke it for GCC11 and replace with it done late, that hunk can be removed. The rest of the patch IMHO can be useful even for later, e.g. union U { struct S { int a : 1, b : 4, c : 27; } s; struct T { int d : 2; int e : 2; int f : 28; } t; }; int foo (void) { union U u; u.s.b = 10; return u.t.e; } wasn't optimized into return 1; until combine without this patch, now fre1 can do it already. Thoughts on this? And, where should the shifting functions from gimple-ssa-store-merging.c go? Either they can stay where they are and have gimple-ssa-store-merging.h that declares them, or say fold-const.[ch]?