This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] combine.c: Remove unnecessary AND when storing into zero_extract.
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Kazu Hirata <kazu at cs dot umass dot edu>
- Cc: gcc-patches at gcc dot gnu dot org, Richard dot Earnshaw at arm dot com
- Date: Fri, 21 Mar 2003 18:00:22 +0000
- Subject: Re: [patch] combine.c: Remove unnecessary AND when storing into zero_extract.
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
> Hi,
>
> Attached is a patch to remove unnecessary AND when storing into
> zero_extract. Consider
>
> A = (A & ~64) | (B & 64);
>
> The combiner eventually suggests
>
> (set (zero_extract:SI (reg:SI A)
> (const_int 1)
> (const_int 6))
> (and:SI (lshiftrt:SI (reg:SI B)
> (const_int 6))
> (const_int 1)))
>
> We are storing only one bit, so the AND in the source is unnecessary.
> The patch causes it to be stripped, resulting in
>
> (set (zero_extract:SI (reg:SI A)
> (const_int 1)
> (const_int 6))
> (lshiftrt:SI (reg:SI B)
> (const_int 6)))
>
> Tested on h8300 port. OK to apply?
>
Surely any mask that is wider than the insertion can be stripped. In the
above case 3, 7, 15,...
R.