Patchwork RFA: Fix middle-end/44769

login
register
mail settings
Submitter Joern Rennecke
Date Nov. 10, 2010, 4:55 p.m.
Message ID <20101110115545.dguw6mjogg0owc0k-nzlynne@webmail.spamcop.net>
Download mbox | patch
Permalink /patch/70649/
State New
Headers show

Comments

Joern Rennecke - Nov. 10, 2010, 4:55 p.m.
Bootstrapping on i686-pc-linux-gnu.
We get the warnings for code that is dead, but the warnings get emitted
anyways because we use effectively if (0) rather than #if 0.
By assigning the shift count to a variable first, we can avoid the
warning for the dead code.

Although we could split the shift or use a conditional, that doesn't
look that good an option here, because BITS_PER_WORD is not always
a constant; for some targets, it depends on a gcc option.
So far, we've evaluated BITS_PER_WORD in this piece of code twice.
Using a split shift or a conditional, we'd evaluate it at least four times.
Moreover, for a split shift count, we'd have the added awkwardness
what to do to make it safe for future targets with add BITS_PER_WORD
(not counting 36, 20 or 22 as odd in this context ;-).

By assigning BITS_PER_UNIT to a variable first, we evaluate it only once.

2010-11-10  Joern Rennecke  <amylaar@spamcop.net>

	PR middle-end/44769
	* final.c (split_double): Don't use BITS_PER_WORD directly in
	shift count.
Richard Henderson - Nov. 12, 2010, 5:15 p.m.
On 11/10/2010 08:55 AM, Joern Rennecke wrote:
> 	PR middle-end/44769
> 	* final.c (split_double): Don't use BITS_PER_WORD directly in
> 	shift count.

Ok.


r~

Patch

Index: final.c
===================================================================
--- final.c	(revision 166491)
+++ final.c	(working copy)
@@ -3807,10 +3807,11 @@  split_double (rtx value, rtx *first, rtx
 	     Sign extend each half to HOST_WIDE_INT.  */
 	  unsigned HOST_WIDE_INT low, high;
 	  unsigned HOST_WIDE_INT mask, sign_bit, sign_extend;
+	  unsigned bits_per_word = BITS_PER_WORD;
 
 	  /* Set sign_bit to the most significant bit of a word.  */
 	  sign_bit = 1;
-	  sign_bit <<= BITS_PER_WORD - 1;
+	  sign_bit <<= bits_per_word - 1;
 
 	  /* Set mask so that all bits of the word are set.  We could
 	     have used 1 << BITS_PER_WORD instead of basing the
@@ -3833,7 +3834,7 @@  split_double (rtx value, rtx *first, rtx
 	  /* Pick the higher word, shifted to the least significant
 	     bits, and sign-extend it.  */
 	  high = INTVAL (value);
-	  high >>= BITS_PER_WORD - 1;
+	  high >>= bits_per_word - 1;
 	  high >>= 1;
 	  high &= mask;
 	  if (high & sign_bit)