From 72b273152f75a8622ea13d0fe95d6d2461615ba4 Mon Sep 17 00:00:00 2001 From: Martin Jambor Date: Mon, 6 Jan 2025 11:58:29 +0100 Subject: [PATCH] ipa-cp: Make dumping of bit masks representing -1 nicer Dumps of the lattices representing bit-values and of propagation results of bit-values can print a really long hexadecimal value when the bit-value represents -1 (all bits set). This patch simply detect that situation and prints the string "-1" in that case, making the dumps somewhat nicer. gcc/ChangeLog: 2025-01-03 Martin Jambor * ipa-cp.cc (ipcp_print_widest_int): New function. (ipcp_store_vr_results): Use it. (ipcp_bits_lattice::print): Likewise. Fix formatting. --- gcc/ipa-cp.cc | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index 7423731d725..294389fba4c 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -307,6 +307,18 @@ ipcp_lattice::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. */ + +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 + print_hex (value, f); +} + void ipcp_bits_lattice::print (FILE *f) { @@ -316,8 +328,10 @@ ipcp_bits_lattice::print (FILE *f) fprintf (f, " Bits unusable (BOTTOM)\n"); else { - fprintf (f, " Bits: value = "); print_hex (get_value (), f); - fprintf (f, ", mask = "); print_hex (get_mask (), f); + fprintf (f, " Bits: value = "); + ipcp_print_widest_int (f, get_value ()); + fprintf (f, ", mask = "); + print_hex (get_mask (), f); fprintf (f, "\n"); } } @@ -6375,7 +6389,7 @@ ipcp_store_vr_results (void) dumped_sth = true; } fprintf (dump_file, " param %i: value = ", i); - print_hex (bits->get_value (), dump_file); + ipcp_print_widest_int (dump_file, bits->get_value ()); fprintf (dump_file, ", mask = "); print_hex (bits->get_mask (), dump_file); fprintf (dump_file, "\n");