Issue 115862
Summary [MachineLICM][MachineSink] Sinking invariants into cycle
Labels llvm:codegen, llvm:optimizations
Assignees DianQK
Reporter DianQK
    There is a performance regression from https://github.com/rust-lang/rust/issues/132636. I haven’t created a C or LLVM IR example yet, but I believe this issue is mainly due to LICM hoisting numerous invariants, which causes register spills.

Currently, LICM hoists all invariants, regardless of whether it increases register pressure or if the code always executes. MachineSink (formerly [in MachineLICM]((https://reviews.llvm.org/D93694))) then attempts to sink these invariants to mitigate register pressure. After reading the related code, it appears that MachineSink doesn’t handle this well; it doesn’t even enable [`-sink-insts-to-avoid-spills`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.3/llvm/lib/CodeGen/MachineSink.cpp#L98-L102). Some of the test cases also don’t seem to work as expected, such as [machine-licm-sink-instr.ll](https://github.com/llvm/llvm-project/blob/e385e0d3e71e17da0b2023f480259c95923707bd/llvm/test/CodeGen/AArch64/machine-licm-sink-instr.ll).

I don’t think the patch requires an RFC, but I would still like to get some feedback. I purpose to move this code back into MachineLICM and modify it to a new process:

1. LICM still hoists all invariants.
2. MachineLICM sinks all invariants as a preprocessing step.
3. MachineLICM considers factors like register pressure and conditional execution re-hoists invariants, aiming to improve runtime performance.

This way, we won’t need to maintain a separate set of code in MachineSink that opposite MachineLICM.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to