This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] combine.c: Remove unnecessary AND when storing into zero_extract.


> 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.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]