Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MachineLICM][MachineSink] Sinking invariants into cycle #115862

Open
dianqk opened this issue Nov 12, 2024 · 0 comments
Open

[MachineLICM][MachineSink] Sinking invariants into cycle #115862

dianqk opened this issue Nov 12, 2024 · 0 comments

Comments

@dianqk
Copy link
Member

dianqk commented Nov 12, 2024

There is a performance regression from rust-lang/rust#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) 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. Some of the test cases also don’t seem to work as expected, such as 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant