]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR target/53385 ("Error: operand out of range" after changes for LSHIFT_...
authorBill Schmidt <wschmidt@linux.vnet.ibm.com>
Thu, 24 May 2012 13:52:56 +0000 (13:52 +0000)
committerWilliam Schmidt <wschmidt@gcc.gnu.org>
Thu, 24 May 2012 13:52:56 +0000 (13:52 +0000)
2012-05-24  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

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

PR target/53385
* config/rs6000/rs6000.c (print_operand): Revise code that unsafely
relied on signed overflow behavior.

From-SVN: r187834

gcc/ChangeLog
gcc/config/rs6000/rs6000.c

index 18396fa29e2291e19d4c50eee695787c47b3e62a..9be8483f8ca3320c9464faa9ad8370e5cf772321 100644 (file)
@@ -1,3 +1,12 @@
+2012-05-24  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
+
+       Backport from mainline
+        2012-05-18  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
+
+       PR target/53385
+       * config/rs6000/rs6000.c (print_operand): Revise code that unsafely
+       relied on signed overflow behavior.
+
 2012-05-22  Richard Guenther  <rguenther@suse.de>
 
        Backport from mainline
index 5c101a51affac5f6b377cb7fcabd06a796cd638a..36aba430eb933fa56638d3937db4ce0e62be0496 100644 (file)
@@ -15822,7 +15822,6 @@ void
 print_operand (FILE *file, rtx x, int code)
 {
   int i;
-  HOST_WIDE_INT val;
   unsigned HOST_WIDE_INT uval;
 
   switch (code)
@@ -16263,34 +16262,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));
-
-      if (val < 0)
-       i = -1;
-      else
-       for (i = 0; i < HOST_BITS_PER_WIDE_INT; i++)
-         if ((val <<= 1) < 0)
-           break;
+      i = clz_hwi (GET_CODE (x) == CONST_INT
+                  ? INTVAL (x) : CONST_DOUBLE_HIGH (x));
 
 #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':