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]

revised patch committed.


Amir,

I tested and committed a slightly different and cleaned up version of
this patch with a proper changelog.  It would be good if you reported
back the results of request by Paolo in case that shows any problems.

We unfortunately cannot directly accept patches from people that do
not have a gcc/gnu copyright assignment.    We would strongly recommend
that you go through the trouble to get this.   It makes it much easier
to interact with the rest of the gcc community.  You can contact David
Edelsohn <edelsohn@gnu.org> for details on how to do this.

Thanks for the bug report and patch.   We appreciate the help.

Iant confirmed today via irc that the rtl that was generated in this private
port was legitimate.   I tested my patch on x86-64 to make sure that I
did not break anything.  

My patch was committed as revision 153924.

Kenny




> gcc-4.4.1, proprietary backend)
> 
> Hi,
> It looks like fwprop does not propagate addresses that appear in
> zero_extract on the set dest.
> Here is an example:
> 
> (insn 8 5 9 2 c:\mingw\home\amirg\test\test.c:157 (set (reg/f:HI 46)
>         (const:HI (plus:HI (symbol_ref:HI ("r") [flags 0x40] <var_decl
> 0x2ee40b0 r>)
>                 (const_int 68 [0x44])))) 18 {*movhi} (nil))
> 
> (insn 9 8 0 2 c:\mingw\home\amirg\test\test.c:157 (set
> (zero_extract:SI (mem/s/j:QI (plus:HI (reg/f:HI 46)
>                     (const_int 2 [0x2])) [0 S1 A8])
>             (const_int 1 [0x1])
>             (const_int 1 [0x1]))
>         (const_int 0 [0x0])) 29 {*movb_lh} (nil))
> 
> The problem seems to be in df_scan.c: df_uses_record doesn't handle
> the case of (set (zero_extract(mem(...) ...) ...).
> So I tried the following patch in df_uses_record under case SET: ...
> case ZERO_EXTRACT: ...
> 
> --- df-scan.c
> +++ df-scan.c
> @@ -3152,11 +3152,24 @@
>  		  {
>  		    width = INTVAL (XEXP (dst, 1));
>  		    offset = INTVAL (XEXP (dst, 2));
> -		    mode = GET_MODE (dst);
> +		    mode = GET_MODE (dst);			
> +			/* AG start */
> +			/* Handle the case of zero_extract(mem(...)) in the set dest */
> +			if (GET_CODE (XEXP (dst,0)) == MEM)
> +			{
> +			df_uses_record (DF_REF_EXTRACT, collection_rec, &XEXP (XEXP (dst,0), 0),
> +				  DF_REF_REG_MEM_STORE, bb, insn_info,
> +				  DF_REF_ZERO_EXTRACT,
> +				  width, offset, mode);
> +			}
> +			else
> +			{
> +			/* AG end */
>  		    	df_uses_record (DF_REF_EXTRACT, collection_rec, &XEXP (dst, 0),
>  				DF_REF_REG_USE, bb, insn_info,
>  				DF_REF_READ_WRITE | DF_REF_ZERO_EXTRACT,
>  				width, offset, mode);
> +			} /* AG added closing brackets */
>  		  }
>  		else
>  		  {
> 
> and now fwprop propagates properly:
> 
> (insn 9 5 0 2 c:\mingw\home\amirg\test\test.c:157 (set
> (zero_extract:SI (mem/s/j:QI (const:HI (plus:HI (symbol_ref:HI ("r")
> [flags 0x40] <var_decl 0x2ee40b0 r>)
>                         (const_int 70 [0x46]))) [0 S1 A8])
>             (const_int 1 [0x1])
>             (const_int 1 [0x1]))
>         (const_int 0 [0x0])) 29 {*movb_lh} (nil))
> 
> I'll appreciate any comments,
> Thanks,
> 
> Amir
> 

===File ~/gcc/patches/dataflow/scanfix2.diff================
Index: gcc/df-scan.c
===================================================================
--- gcc/df-scan.c       (revision 153920)
+++ gcc/df-scan.c       (working copy)
@@ -3248,10 +3248,23 @@ df_uses_record (enum df_ref_class cl, st
                    width = INTVAL (XEXP (dst, 1));
                    offset = INTVAL (XEXP (dst, 2));
                    mode = GET_MODE (dst);
-                   df_uses_record (DF_REF_EXTRACT, collection_rec, &XEXP (dst, 0), 
-                               DF_REF_REG_USE, bb, insn_info, 
-                               DF_REF_READ_WRITE | DF_REF_ZERO_EXTRACT, 
-                               width, offset, mode);
+                   if (GET_CODE (XEXP (dst,0)) == MEM)
+                     {
+                       /* Handle the case of zero_extract(mem(...)) in the set dest.
+                          This special case is allowed only if the mem is a single byte and 
+                          is useful to set a bitfield in memory.  */
+                       df_uses_record (DF_REF_EXTRACT, collection_rec, &XEXP (XEXP (dst,0), 0),
+                                       DF_REF_REG_MEM_STORE, bb, insn_info,
+                                       DF_REF_ZERO_EXTRACT,
+                                       width, offset, mode);
+                     }
+                   else
+                     {
+                       df_uses_record (DF_REF_EXTRACT, collection_rec, &XEXP (dst, 0), 
+                                       DF_REF_REG_USE, bb, insn_info, 
+                                       DF_REF_READ_WRITE | DF_REF_ZERO_EXTRACT, 
+                                       width, offset, mode);
+                     }
                  }
                else 
                  {
============================================================


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