This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Improve liveness copying in si-optimize-exec-masking-pre-ra
ClosedPublic

Authored by critson on Jul 12 2022, 3:58 AM.

Details

Summary

Further improve liveness copying for CC register post optimization
by mirroring live internal splits.
The fixes a bug in register allocation when CC register liveness
is extended across a branches instead of split.

Diff Detail

Event Timeline

critson created this revision.Jul 12 2022, 3:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2022, 3:58 AM
critson requested review of this revision.Jul 12 2022, 3:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2022, 3:58 AM

I am still working on suitably simple test case.

arsenm added inline comments.Jul 12 2022, 10:59 AM
llvm/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp
194–195

I'm increasingly worried about just ignoring physical registers. Is there a reason why we bother to try handling them here?

critson marked an inline comment as done.Jul 12 2022, 6:45 PM
critson added inline comments.
llvm/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp
194–195

Thanks for pointing this out.
We don't need to handle physical register for SelReg anymore as do not optimize these anymore.
I've simplified the code.

critson updated this revision to Diff 444136.Jul 12 2022, 6:45 PM
critson marked an inline comment as done.
  • Simplify code based on not handling physical registers
critson updated this revision to Diff 444138.Jul 12 2022, 7:55 PM
  • Add test, unfortunately this has to be a bug specific MIR test from an llvm-reduce
arsenm added inline comments.Jul 13 2022, 7:39 AM
llvm/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp
192

Don't need the &

llvm/test/CodeGen/AMDGPU/optimize-exec-mask-pre-ra-alloc-failure.mir
1 ↗(On Diff #444138)

Don't need -mattr. Also I would prefer specifying the specific greedy run, and run to the end of virtregrewriter

12 ↗(On Diff #444138)

Can drop register section (and then compact the numbers with -run-pass=none)

critson marked 3 inline comments as done.Jul 13 2022, 8:06 PM
critson added inline comments.
llvm/test/CodeGen/AMDGPU/optimize-exec-mask-pre-ra-alloc-failure.mir
12 ↗(On Diff #444138)

I have dropped all the register definitions that did not change the test result, 3 with preferred register values of $vcc remain.

critson updated this revision to Diff 444503.Jul 13 2022, 8:06 PM
critson marked an inline comment as done.
  • Address reviewer comments
cdevadas added inline comments.
llvm/test/CodeGen/AMDGPU/optimize-exec-mask-pre-ra-alloc-failure.mir
1 ↗(On Diff #444503)

How do the two '-stop-after' fields work here?

arsenm added inline comments.Jul 14 2022, 7:02 AM
llvm/test/CodeGen/AMDGPU/optimize-exec-mask-pre-ra-alloc-failure.mir
1 ↗(On Diff #444138)

Should only have one stop-after. I think the second one wins

arsenm added inline comments.Jul 14 2022, 7:26 AM
llvm/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp
227

Typo defintion. The assert seems a bit redundant with the FindSegmentContaining below

arsenm added inline comments.Jul 14 2022, 7:57 AM
llvm/test/CodeGen/AMDGPU/optimize-exec-mask-pre-ra-alloc-failure.mir
26 ↗(On Diff #444503)

Should drop the register types

critson updated this revision to Diff 444905.Jul 15 2022, 12:44 AM
  • Address reviewer comments
critson marked 4 inline comments as done.Jul 15 2022, 12:47 AM
critson added inline comments.
llvm/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp
227

Fixed the typo.
I would prefer to the keep the assertion because while the code won't fail without segment, it suggest something is wrong which will impact code gen.

llvm/test/CodeGen/AMDGPU/optimize-exec-mask-pre-ra-alloc-failure.mir
26 ↗(On Diff #444503)

I assume you mean the variable specification (p3) or (p4), I have removed these.
The register type information is required on most instructions for code gen.

arsenm accepted this revision.Jul 16 2022, 6:28 AM
arsenm added inline comments.
llvm/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp
227

I mean you could assert FindSegmentContaining isn't the end

This revision is now accepted and ready to land.Jul 16 2022, 6:28 AM
This revision was landed with ongoing or failed builds.Jul 17 2022, 1:34 AM
This revision was automatically updated to reflect the committed changes.
critson marked 2 inline comments as done.