The checkin r181279 which speeds up the printing of integer constants
caused PR 51144 and broke the IA64 and s390 bootstraps.

The problem is with fprint_w which takes a HOST_WIDE_INT value argument
and uses sprint_ul_rev to process it.  But sprint_ul_rev takes a long
argument so if the argument to fprint_w is 'long long' and is larger
then can fit into a long argument the function winds up truncating the
value.  This happens on IA64 HP-UX in 32 bit mode where 'long' is 32
bits and HOST_WIDE_INT (long long) is 64 bits.

Rather then try to fix fprint_w I would like to just go back to using
fprintf for this particular output.

Testing on IA64 HP-UX shows that this fixes the bootstrap failure and
it found no regressions.  Presumably it does slow down the compilation
slightly since the point of fprint_w was to be faster then fprintf.

If someone (Dimitrios?) wants to fix fprint_w instead of removing it
that is fine with me but if no one does that I would like to have
this patch approved to fix the bootstrap failure.

Steve Ellcey
s...@cup.hp.com


2011-11-17  Steve Ellcey  <s...@cup.hp.com>

        PR middle-end/51144
        * output.h (fprint_w): Remove.
        * final.c (fprint_w): Remove.
        (output_addr_const): Change fprint_w back to fprintf.


Index: output.h
===================================================================
--- output.h    (revision 181435)
+++ output.h    (working copy)
@@ -129,7 +129,6 @@ typedef HOST_WIDE_INT __gcc_host_wide_in
 #define ATTRIBUTE_ASM_FPRINTF(m, n) ATTRIBUTE_NONNULL(m)
 #endif
 
-extern void fprint_w (FILE *, HOST_WIDE_INT);
 extern void fprint_whex (FILE *, unsigned HOST_WIDE_INT);
 extern void fprint_ul (FILE *, unsigned long);
 extern int sprint_ul (char *, unsigned long);
Index: final.c
===================================================================
--- final.c     (revision 181435)
+++ final.c     (working copy)
@@ -3585,7 +3585,7 @@ output_addr_const (FILE *file, rtx x)
       break;
 
     case CONST_INT:
-      fprint_w (file, INTVAL (x));
+      fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x));
       break;
 
     case CONST:
@@ -3741,33 +3741,6 @@ sprint_ul_rev (char *s, unsigned long va
   return i;
 }
 
-/* Write a signed HOST_WIDE_INT as decimal to a file, fast. */
-
-void
-fprint_w (FILE *f, HOST_WIDE_INT value)
-{
-  /* python says: len(str(2**64)) == 20 */
-  char s[20];
-  int i;
-
-  if (value >= 0)
-    i = sprint_ul_rev (s, (unsigned long) value);
-  else
-    {
-      /* Cast to long long to output max negative correctly! */
-      i = sprint_ul_rev (s, ((unsigned long long) value) * -1);
-      putc('-', f);
-    }
-
-  /* It's probably too small to bother with string reversal and fputs. */
-  do
-    {
-      i--;
-      putc (s[i], f);
-    }
-  while (i != 0);
-}
-
 /* Write an unsigned long as decimal to a file, fast. */
 
 void

Reply via email to