public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Minor tweak to extract_bit_field_1
@ 2013-06-04  7:41 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2013-06-04  7:41 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 600 bytes --]

For the larger-than-a-word case, store_bit_field_1 factors out the processing 
order into a 'backwards' local variable:

      unsigned int backwards = WORDS_BIG_ENDIAN && fieldmode != BLKmode;

and uses it consistently afterward.  There is the symmetrical processing in 
extract_bit_field_1 and it doesn't factor out the processing order.

Tested on PowerPC/Linux, applied on the mainline as obvious.


2013-06-04  Eric Botcazou  <ebotcazou@adacore.com>

	* expmed.c (extract_bit_field_1): In the larger-than-a-word case, factor
	out the processing order as in store_bit_field_1.


-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 1531 bytes --]

Index: expmed.c
===================================================================
--- expmed.c	(revision 199590)
+++ expmed.c	(working copy)
@@ -1486,6 +1486,7 @@ extract_bit_field_1 (rtx str_rtx, unsign
 	 This is because the most significant word is the one which may
 	 be less than full.  */
 
+      unsigned int backwards = WORDS_BIG_ENDIAN;
       unsigned int nwords = (bitsize + (BITS_PER_WORD - 1)) / BITS_PER_WORD;
       unsigned int i;
       rtx last;
@@ -1503,13 +1504,14 @@ extract_bit_field_1 (rtx str_rtx, unsign
 	     if I is 1, use the next to lowest word; and so on.  */
 	  /* Word number in TARGET to use.  */
 	  unsigned int wordnum
-	    = (WORDS_BIG_ENDIAN
+	    = (backwards
 	       ? GET_MODE_SIZE (GET_MODE (target)) / UNITS_PER_WORD - i - 1
 	       : i);
 	  /* Offset from start of field in OP0.  */
-	  unsigned int bit_offset = (WORDS_BIG_ENDIAN
-				     ? MAX (0, ((int) bitsize - ((int) i + 1)
-						* (int) BITS_PER_WORD))
+	  unsigned int bit_offset = (backwards
+				     ? MAX ((int) bitsize - ((int) i + 1)
+					    * BITS_PER_WORD,
+					    0)
 				     : (int) i * BITS_PER_WORD);
 	  rtx target_part = operand_subword (target, wordnum, 1, VOIDmode);
 	  rtx result_part
@@ -1541,7 +1543,7 @@ extract_bit_field_1 (rtx str_rtx, unsign
 	      for (i = nwords; i < total_words; i++)
 		emit_move_insn
 		  (operand_subword (target,
-				    WORDS_BIG_ENDIAN ? total_words - i - 1 : i,
+				    backwards ? total_words - i - 1 : i,
 				    1, VOIDmode),
 		   const0_rtx);
 	    }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-06-04  7:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-04  7:41 Minor tweak to extract_bit_field_1 Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).