[llvm] [RISCV] Add Statistics for Fusions (PR #186499)
Pengcheng Wang via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 13 20:58:40 PDT 2026
https://github.com/wangpc-pp commented:
I had the same thought to generate statistics when emitting predicator but I didn't have time to implement it.
My thought is:
1. Add a new field `bit GenerateStatistic = 1` to class `Fusion`, in case people don't want these statistics. We may don't need this controversially.
2. Add a new macro `GET_<TARGET>_MACRO_FUSION_STATISTICS` to guard these statistics in <TARGET>Subtarget, which also defines `ENABLE_STATISTIC`.
3. Add a code snippet guarded by `ENABLE_STATISTIC` in each predicator and increase the STATISTIC when fusion is matched.
I think you have implemented the major part now. :-)
One concern: we have enabled both pre-ra scheduler and post-ra scheduler, so we will run MacroFusion twice. The statistics may not be precise and we need to distinguish pre-ra and post-ra. I haven't thought of a solution.
https://github.com/llvm/llvm-project/pull/186499
More information about the llvm-commits
mailing list