On Wed, Aug 28, 2024 at 6:34 AM Andrew Pinski <quic_apin...@quicinc.com> wrote: > > 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. > > 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 | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc > index 89da13b38ce..91210976a0a 100644 > --- a/gcc/internal-fn.cc > +++ b/gcc/internal-fn.cc > @@ -5351,6 +5351,14 @@ 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, cost\n"); > + fprintf(dump_file, "popcount: %u\n", popcount_cost); > + fprintf(dump_file, "cmp: %u\n\n", cmp_cost);
Can you make this more brief in a single line, like choice for popcount == 1: popcount cost: %u; cmp cost: %u\n ? OK with that change. > + } > + > if (popcount_cost <= cmp_cost) > emit_insn (popcount_insns); > else > -- > 2.43.0 >