This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Add peepholes to optimize reg0=mem1;reg0 op=nonmem2;mem1=reg0;if(reg0!=0) (PR rtl-optimization/49194)
- From: Uros Bizjak <ubizjak at gmail dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 29 May 2011 20:41:18 +0200
- Subject: Re: [PATCH] Add peepholes to optimize reg0=mem1;reg0 op=nonmem2;mem1=reg0;if(reg0!=0) (PR rtl-optimization/49194)
- References: <20110527164052.GC17079@tyan-ft48-01.lab.bos.redhat.com>
On Fri, May 27, 2011 at 6:40 PM, Jakub Jelinek <jakub@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 ?<jakub@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.