On 11/16/26 1:57 AM, Bohan Lei wrote:
This commit tries hoist VXRM writes to preheaders on microarchs that
have a pipeline flush on such CSR write. The main motivation of this
patch is x264, as after the LTO patches, some get_ref related functions
get inlined into callers and VXRM can no longer be hoisted to the
function epilogue. This version currently only handles those in
innermost loops. The tuning parameters are added as per the LLVM
handling of the similar optimization.
Related testcases were run manually. Regression tests on rv64gcv and
rv32gcv in flight.
This seems a lot more complex than it needs to be. Can't we just handle
the calls less pessimistically and let the LCM algorithm otherwise do
its job? I don't think we need to do loop discovery/analysis or
anything like that. I *think* if we do something more sensible on the
call sites the LCM algorithm will just work.
And if we're going to do that, let's just do it unconditionally. VXRM
stuff is very uncommon and in the cases were it matters, unconditional
aggressive hoisting seems reasonable on both cores that flush the
pipeline and those which have fast paths for VXRM.
There's also a BZ on this issue you should reference. 127086.
Jeff