https://gcc.gnu.org/g:044d0d1ee1a61c21670068485d4a250edfbb695a

commit r15-9428-g044d0d1ee1a61c21670068485d4a250edfbb695a
Author: Martin Jambor <mjam...@suse.cz>
Date:   Mon Apr 14 14:21:15 2025 +0200

    ipa-cp: Make dumping of widest_ints even more sane
    
    This patch just introduces a form of dumping of widest ints that only
    have zeros in the lowest 128 bits so that instead of printing
    thousands of f's the output looks like:
    
           Bits: value = 0xffff, mask = all ones folled by 
0xffffffffffffffffffffffffffff0000
    
    and then makes sure we use the function not only to print bits but
    also to print masks where values like these can also occur.
    
    gcc/ChangeLog:
    
    2025-03-21  Martin Jambor  <mjam...@suse.cz>
    
            * ipa-cp.cc (ipcp_print_widest_int): Also add a truncated form of
            dumping of widest ints which only have zeros in the lowest 128 bits.
            Update the comment.
            (ipcp_bits_lattice::print): Also dump the mask using
            ipcp_print_widest_int.
            (ipcp_store_vr_results): Likewise.

Diff:
---
 gcc/ipa-cp.cc | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index fd2c4cca1365..637bc49f0482 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -307,14 +307,21 @@ ipcp_lattice<valtype>::print (FILE * f, bool 
dump_sources, bool dump_benefits)
     fprintf (f, "\n");
 }
 
-/* If VALUE has all bits set to one, print "-1" to F, otherwise simply print it
-   hexadecimally to F. */
+/* Print VALUE to F in a form which in usual cases does not take thousands of
+   characters. */
 
 static void
 ipcp_print_widest_int (FILE *f, const widest_int &value)
 {
   if (wi::eq_p (wi::bit_not (value), 0))
     fprintf (f, "-1");
+  else if (wi::eq_p (wi::bit_not (wi::bit_or (value,
+                                             wi::sub (wi::lshift (1, 128),
+                                                      1))), 0))
+    {
+      fprintf (f, "all ones folled by ");
+      print_hex (wi::bit_and (value, wi::sub (wi::lshift (1, 128), 1)), f);
+    }
   else
     print_hex (value, f);
 }
@@ -331,7 +338,7 @@ ipcp_bits_lattice::print (FILE *f)
       fprintf (f, "         Bits: value = ");
       ipcp_print_widest_int (f, get_value ());
       fprintf (f, ", mask = ");
-      print_hex (get_mask (), f);
+      ipcp_print_widest_int (f, get_mask ());
       fprintf (f, "\n");
     }
 }
@@ -6437,7 +6444,7 @@ ipcp_store_vr_results (void)
          fprintf (dump_file, " param %i: value = ", i);
          ipcp_print_widest_int (dump_file, bits->get_value ());
          fprintf (dump_file, ", mask = ");
-         print_hex (bits->get_mask (), dump_file);
+         ipcp_print_widest_int (dump_file, bits->get_mask ());
          fprintf (dump_file, "\n");
        }
     }

Reply via email to