Patchwork Fix expansion issues on type changing MEM_REFs on LHS (PR middle-end/48335)

login
register
mail settings
Submitter Eric Botcazou
Date April 1, 2011, 3:35 p.m.
Message ID <201104011735.54196.ebotcazou@adacore.com>
Download mbox | patch
Permalink /patch/89296/
State New
Headers show

Comments

Eric Botcazou - April 1, 2011, 3:35 p.m.
> result is set there from store_field, and result is only used in
>       if (result)
>         preserve_temp_slots (result);
> afterwards.  store_field might want to preserve_temp_slots perhaps, so
> clearing result afterwards might be wrong.

You're very likely right, but then this should apply to the case just above.

> You mean just with the MEM_P test?  So something like:
>
> @@ -418,8 +418,11 @@ store_bit_field_1 (rtx str_rtx, unsigned
>        && bitsize == GET_MODE_BITSIZE (fieldmode)
>        && (!MEM_P (op0)
>  	  ? ((GET_MODE_SIZE (fieldmode) >= UNITS_PER_WORD
> -	     || GET_MODE_SIZE (GET_MODE (op0)) == GET_MODE_SIZE (fieldmode))
> -	     && byte_offset % GET_MODE_SIZE (fieldmode) == 0)
> +	      || GET_MODE_SIZE (GET_MODE (op0)) == GET_MODE_SIZE (fieldmode))
> +	     && byte_offset % GET_MODE_SIZE (fieldmode) == 0
> +	     && (GET_MODE (op0) == fieldmode
> +		 || validate_subreg (fieldmode, GET_MODE (op0), op0,
> +				     byte_offset)))
>
>  	  : (! SLOW_UNALIGNED_ACCESS (fieldmode, MEM_ALIGN (op0))
>  	  :
>  	     || (offset * BITS_PER_UNIT % bitsize == 0
>
>  		 && MEM_ALIGN (op0) % GET_MODE_BITSIZE (fieldmode) == 0))))
>
> instead?

Yes, but I think that this can be further simplified.  The test:

  byte_offset % GET_MODE_SIZE (fieldmode) == 0

is the first thing the call to validate_subreg does.  And it's clear that the 
case GET_MODE (op0) == fieldmode requires byte_offset to be 0.  So I think:


should work.

Patch

Index: expmed.c
===================================================================
--- expmed.c    (revision 171818)
+++ expmed.c    (working copy)
@@ -419,7 +419,9 @@  store_bit_field_1 (rtx str_rtx, unsigned
       && (!MEM_P (op0)
          ? ((GET_MODE_SIZE (fieldmode) >= UNITS_PER_WORD
             || GET_MODE_SIZE (GET_MODE (op0)) == GET_MODE_SIZE (fieldmode))
-            && byte_offset % GET_MODE_SIZE (fieldmode) == 0)
+            && ((GET_MODE (op0) == fieldmode && byte_offset == 0)
+                || validate_subreg (fieldmode, GET_MODE (op0), op0,
+                                    byte_offset)))
          : (! SLOW_UNALIGNED_ACCESS (fieldmode, MEM_ALIGN (op0))
             || (offset * BITS_PER_UNIT % bitsize == 0
                 && MEM_ALIGN (op0) % GET_MODE_BITSIZE (fieldmode) == 0))))