On Mon, Mar 7, 2022 at 11:55 AM Roger Sayle <ro...@nextmovesoftware.com> wrote: > > > This patch is the backend piece of my proposed fix to PR tree-opt/98335, > to allow C++ partial struct initialization to be as efficient/optimized > as full struct initialization. > > With the middle-end patch just posted to gcc-patches, the test case > in the PR compiles on x86_64-pc-linux-gnu with -O2 to: > > xorl %eax, %eax > movb c(%rip), %al > ret > > with this additional peephole2 (actually pair of peephole2s): > > movzbl c(%rip), %eax > ret > > > This patch has been tested on x86_64-pc-linux-gnu, on top of the > middle-end piece, with make bootstrap and make -k check with no > new failures. Posted in pieces to simplify review. Ok for mainline?
Is there a reason that only inserts to DImode registers are implemented? IMO, these peepholes should also handle inserts to SImode. Uros. > > 2022-03-07 Roger Sayle <ro...@nextmovesoftware.com> > > gcc/ChangeLog > PR tree-optimization/98335 > * config/i386/i386.md (peephole2): Transform xorl followed by > a suitable movb or movw into the equivalent movz[bw]l. > > gcc/testsuite/ChangeLog > PR tree-optimization/98335 > * g++.target/i386/pr98335.C: New test case. > > > Thanks in advance, > Roger > -- >