Patchwork [rs6000] Fix PR53385

login
register
mail settings
Submitter William J. Schmidt
Date May 18, 2012, 3 p.m.
Message ID <1337353224.25646.19.camel@gnopaine>
Download mbox | patch
Permalink /patch/160127/
State New
Headers show

Comments

William J. Schmidt - May 18, 2012, 3 p.m.
This repairs the bootstrap issue due to unsafe signed overflow
assumptions.  Bootstrapped and tested on powerpc64-unknown-linux-gnu
with no new regressions.  Ok for trunk?

Thanks,
Bill


2012-05-18  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	* config/rs6000/rs6000.c (print_operand): Revise code that unsafely
	relied on signed overflow behavior.
David Edelsohn - May 18, 2012, 3:49 p.m.
On Fri, May 18, 2012 at 11:00 AM, William J. Schmidt
<wschmidt@linux.vnet.ibm.com> wrote:
> This repairs the bootstrap issue due to unsafe signed overflow
> assumptions.  Bootstrapped and tested on powerpc64-unknown-linux-gnu
> with no new regressions.  Ok for trunk?
>
> Thanks,
> Bill
>
>
> 2012-05-18  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
>
>        * config/rs6000/rs6000.c (print_operand): Revise code that unsafely
>        relied on signed overflow behavior.

Okay.

Thanks, David
Jakub Jelinek - May 18, 2012, 4:27 p.m.
On Fri, May 18, 2012 at 11:49:41AM -0400, David Edelsohn wrote:
> On Fri, May 18, 2012 at 11:00 AM, William J. Schmidt
> <wschmidt@linux.vnet.ibm.com> wrote:
> > This repairs the bootstrap issue due to unsafe signed overflow
> > assumptions.  Bootstrapped and tested on powerpc64-unknown-linux-gnu
> > with no new regressions.  Ok for trunk?

I think it should eventually be applied to all open release branches as
well, but give it some time on the trunk first.

	Jakub

Patch

Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(revision 187651)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -14679,7 +14679,6 @@  void
 print_operand (FILE *file, rtx x, int code)
 {
   int i;
-  HOST_WIDE_INT val;
   unsigned HOST_WIDE_INT uval;
 
   switch (code)
@@ -15120,34 +15119,17 @@  print_operand (FILE *file, rtx x, int code)
 
     case 'W':
       /* MB value for a PowerPC64 rldic operand.  */
-      val = (GET_CODE (x) == CONST_INT
-	     ? INTVAL (x) : CONST_DOUBLE_HIGH (x));
+      i = clz_hwi (GET_CODE (x) == CONST_INT
+		   ? INTVAL (x) : CONST_DOUBLE_HIGH (x));
 
-      if (val < 0)
-	i = -1;
-      else
-	for (i = 0; i < HOST_BITS_PER_WIDE_INT; i++)
-	  if ((val <<= 1) < 0)
-	    break;
-
 #if HOST_BITS_PER_WIDE_INT == 32
-      if (GET_CODE (x) == CONST_INT && i >= 0)
+      if (GET_CODE (x) == CONST_INT && i > 0)
 	i += 32;  /* zero-extend high-part was all 0's */
       else if (GET_CODE (x) == CONST_DOUBLE && i == 32)
-	{
-	  val = CONST_DOUBLE_LOW (x);
-
-	  gcc_assert (val);
-	  if (val < 0)
-	    --i;
-	  else
-	    for ( ; i < 64; i++)
-	      if ((val <<= 1) < 0)
-		break;
-	}
+	i = clz_hwi (CONST_DOUBLE_LOW (x)) + 32;
 #endif
 
-      fprintf (file, "%d", i + 1);
+      fprintf (file, "%d", i);
       return;
 
     case 'x':