]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
expand: Add debug dump on the cost for `popcount==1` expand
authorAndrew Pinski <quic_apinski@quicinc.com>
Mon, 26 Aug 2024 22:14:24 +0000 (15:14 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Wed, 28 Aug 2024 21:03:49 +0000 (14:03 -0700)
While working on PR 114224, I found it would be useful to dump the
different costs of the expansion to make easier to understand why one
was chosen over the other.

Changes since v1:
* v2: make the dump a single line

Bootstrapped and tested on x86_64-linux-gnu.
Build and tested for aarch64-linux-gnu.

gcc/ChangeLog:

* internal-fn.cc (expand_POPCOUNT): Dump the costs for
the two choices.

gcc/internal-fn.cc

index 89da13b38ce1d42a56b9bb63a9fa74fd167bd915..78997ef056ad5f1e8be196bc9e48f6c8044f119a 100644 (file)
@@ -5351,6 +5351,11 @@ expand_POPCOUNT (internal_fn fn, gcall *stmt)
   unsigned popcount_cost = (seq_cost (popcount_insns, speed_p)
                            + seq_cost (popcount_cmp_insns, speed_p));
   unsigned cmp_cost = seq_cost (cmp_insns, speed_p);
+
+  if (dump_file && (dump_flags & TDF_DETAILS))
+    fprintf(dump_file, "popcount == 1: popcount cost: %u; cmp cost: %u\n",
+           popcount_cost, cmp_cost);
+
   if (popcount_cost <= cmp_cost)
     emit_insn (popcount_insns);
   else