]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ipa-cp: Make dumping of bit masks representing -1 nicer
authorMartin Jambor <mjambor@suse.cz>
Mon, 6 Jan 2025 10:58:29 +0000 (11:58 +0100)
committerMartin Jambor <jamborm@gcc.gnu.org>
Mon, 6 Jan 2025 10:58:51 +0000 (11:58 +0100)
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  <mjambor@suse.cz>

* 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

index 7423731d7250ff463ee238ba0104d7d3e833872d..294389fba4c7328b69ad56c5a0f0dbb888657986 100644 (file)
@@ -307,6 +307,18 @@ 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. */
+
+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");