On Tue, Dec 21, 2021 at 4:08 PM Roger Sayle <ro...@nextmovesoftware.com> wrote: > > > This is the second part of my fix to PR target/103773 where -Oz shouldn't > use push/pop on x86 to shrink writing small integer constants to memory. > Instead clang uses "andl $0, mem" for writing zero, and "orl $-1, mem" > when writing -1 to memory when using -Oz. This patch implements this > via peephole2 where we can confirm that its ok to clobber the flags. > > On the CSiBE benchmark, this reduces total code size from 3664172 bytes > to 3663304 bytes, saving 868 bytes. > > This patch has been tested on x86_64-pc-linux-gnu with make bootstrap > and make -k check with no new failures, and the new testcase checked > both with and without -m32. Ok for mainline? > > > 2021-12-21 Roger Sayle <ro...@nextmovesoftware.com> > > gcc/ChangeLog > * gcc/config/i386/i386.md (define_peephole2): With -Oz use > andl $0,mem instead of movl $0,mem and orl $-1,mem instead of > movl $-1,mem.
Your approach uses access to uninitialized memory, which may confuse optimizers. Please rather enhance *mov<mode>_xor and *mov<mode>_or to accept memory operand and convert to these patterns. Uros. > gcc/testsuite/ChangeLog > * gcc.target/i386/pr103773-2.c: New test case. > > > Thanks in advance (and my apologies for the breakage). > Roger > -- >