Skip to content

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

Open
@dianqk

Description

@dianqk

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions