diff mbox

[4/8] Separate reg and mem uses of insv and ext(z)v

Message ID 871ugfix0x.fsf@talisman.home
State New
Headers show

Commit Message

Richard Sandiford Oct. 30, 2012, 7:23 p.m. UTC
This patch simply separates out the MEM and non-MEM insv and ext(z)v cases.
On it's own, it's probably a wash whether this is an improvement or not,
but it makes the optabs patches much easier.

Tested as described in the covering note.  OK to install?

Richard


gcc/
	* expmed.c (store_bit_field_1): Move generation of MEM insvs
	to the MEM_P block.
	(extract_bit_field_1): Likewise extvs and extzvs.

Comments

Eric Botcazou Oct. 30, 2012, 10:16 p.m. UTC | #1
> gcc/
> 	* expmed.c (store_bit_field_1): Move generation of MEM insvs
> 	to the MEM_P block.
> 	(extract_bit_field_1): Likewise extvs and extzvs.

I guess it's in keeping with your earlier changes in these functions.
diff mbox

Patch

Index: gcc/expmed.c
===================================================================
--- gcc/expmed.c	2012-10-28 10:55:22.754350385 +0000
+++ gcc/expmed.c	2012-10-28 10:55:29.249350370 +0000
@@ -784,16 +784,7 @@  store_bit_field_1 (rtx str_rtx, unsigned
 
   enum machine_mode op_mode = mode_for_extraction (EP_insv, 3);
   if (op_mode != MAX_MACHINE_MODE
-      /* Do not use insv for volatile bitfields when
-         -fstrict-volatile-bitfields is in effect.  */
-      && !(MEM_P (op0) && MEM_VOLATILE_P (op0)
-	   && flag_strict_volatile_bitfields > 0)
-      /* Do not use insv if the bit region is restricted and
-	 op_mode integer at offset doesn't fit into the
-	 restricted region.  */
-      && !(MEM_P (op0) && bitregion_end
-	   && bitnum - (bitnum % BITS_PER_UNIT) + GET_MODE_BITSIZE (op_mode)
-	      > bitregion_end + 1)
+      && !MEM_P (op0)
       && store_bit_field_using_insv (op0, bitsize, bitnum, value, op_mode))
     return true;
 
@@ -804,6 +795,18 @@  store_bit_field_1 (rtx str_rtx, unsigned
       enum machine_mode bestmode;
       unsigned HOST_WIDE_INT maxbits = MAX_FIXED_MODE_SIZE;
 
+      /* Do not use insv for volatile bitfields when
+         -fstrict-volatile-bitfields is in effect.  */
+      if (!(MEM_VOLATILE_P (op0) && flag_strict_volatile_bitfields > 0)
+	  /* Do not use insv if the bit region is restricted and
+	     an op_mode integer doesn't fit into the restricted region.  */
+	  && !(bitregion_end
+	       && (bitnum - (bitnum % BITS_PER_UNIT)
+		   + GET_MODE_BITSIZE (op_mode)
+		   > bitregion_end + 1))
+	  && store_bit_field_using_insv (op0, bitsize, bitnum, value, op_mode))
+	return true;
+
       if (bitregion_end)
 	maxbits = bitregion_end - bitregion_start + 1;
 
@@ -1594,11 +1597,7 @@  extract_bit_field_1 (rtx str_rtx, unsign
      If OP0 is a register, it too fits within a word.  */
 
   ext_mode = mode_for_extraction (unsignedp ? EP_extzv : EP_extv, 0);
-  if (ext_mode != MAX_MACHINE_MODE
-      /* Do not use extv/extzv for volatile bitfields when
-         -fstrict-volatile-bitfields is in effect.  */
-      && !(MEM_P (op0) && MEM_VOLATILE_P (op0)
-	   && flag_strict_volatile_bitfields > 0))
+  if (ext_mode != MAX_MACHINE_MODE && !MEM_P (op0))
     {
       rtx result = extract_bit_field_using_extv (op0, bitsize, bitnum,
 						 unsignedp, target, mode,
@@ -1613,6 +1612,17 @@  extract_bit_field_1 (rtx str_rtx, unsign
     {
       enum machine_mode bestmode;
 
+      /* Do not use extv/extzv for volatile bitfields when
+         -fstrict-volatile-bitfields is in effect.  */
+      if (!(MEM_VOLATILE_P (op0) && flag_strict_volatile_bitfields > 0))
+	{
+	  rtx result = extract_bit_field_using_extv (op0, bitsize, bitnum,
+						     unsignedp, target, mode,
+						     tmode, ext_mode);
+	  if (result)
+	    return result;
+	}
+
       /* Get the mode to use for inserting into this field.  If
 	 OP0 is BLKmode, get the smallest mode consistent with the
 	 alignment. If OP0 is a non-BLKmode object that is no