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] Fix expansion issues on type changing MEM_REFs on LHS (PR middle-end/48335)


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

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

should work.

-- 
Eric Botcazou


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