On Fri, May 27, 2011 at 6:40 PM, Jakub Jelinek <ja...@redhat.com> wrote:
> This patch adds a few peephole2s to help optimize if (!--*x) etc. > This is something the combiner doesn't and can't easily handle, because in > reg0 = mem1 > reg0 {+,-,&,|,^}= x > mem1 = reg0 > cc = compare (reg0, 0) > reg0 is used also by both the store and compare and there is no dependence > in between them, so for reg0 = mem1; reg0 {+,-,&,|,^}= x; mem1 = reg0 > alone it can't do anything because reg0 is still needed and mem1 {+,-,&,|,^}= > x > doesn't set it, and the compare, being second user of reg0, doesn't have any > LOG_LINKS and thus try_combine isn't called for it at all. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2011-05-27 Jakub Jelinek <ja...@redhat.com> > > PR rtl-optimization/49095 > * config/i386/predicates.md (plusminuslogic_operator): New predicate. > * config/i386/i386.md: Add peepholes for mem {+,-,&,|,^}= x; mem != 0. > > * gcc.target/i386/pr49095.c: New test. This is OK. On a related note, we probably want to set TARGET_READ_MODIFY_WRITE in ix86_option_override_internal when optimize_size is in effect. Thanks, Uros.