This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Override PSet for M0
ClosedPublic

Authored by rampitec on Feb 9 2017, 4:27 PM.

Details

Summary

This change returns empty PSet list for M0 register. Otherwise its
PSet as defined by tablegen is SReg_32. This results in incorrect
register pressure calculation every time an instruction uses M0.
Such uses count as SReg_32 PSet and inadequately increase pressure
on SGPRs.

Diff Detail

Repository
rL LLVM

Event Timeline

rampitec created this revision.Feb 9 2017, 4:27 PM
arsenm added inline comments.Feb 9 2017, 4:49 PM
lib/Target/AMDGPU/SIRegisterInfo.cpp
1336–1337

Is == M0 sufficient? m0 should be its own regunit since it can't be a subregister

test/CodeGen/AMDGPU/schedule-regpressure.mir
2

This is going to break in a release build

2

Better would be a test that doesn't rely on debug output, but if that's not possible you need REQUIRES: asserts or something like that

rampitec updated this revision to Diff 87919.Feb 9 2017, 4:53 PM

Added # REQUIRES: asserts to the test.

rampitec marked 2 inline comments as done.Feb 9 2017, 4:55 PM
rampitec added inline comments.
lib/Target/AMDGPU/SIRegisterInfo.cpp
1336–1337

Yes, it is in its own RegUnit, and RegUnit is what we get here. This test yields true for M0 and only for M0 because it does not share a RegUnit with any other register.

arsenm added inline comments.Feb 9 2017, 4:59 PM
lib/Target/AMDGPU/SIRegisterInfo.cpp
1336–1337

I mean it's simpler to do just return RegUnit == AMDGPU::M0 instead of doing the whole regunit iterator test

rampitec marked 3 inline comments as done.Feb 9 2017, 5:01 PM
rampitec added inline comments.
lib/Target/AMDGPU/SIRegisterInfo.cpp
1336–1337

AMDGPU::M0 == 89, its RegUnit == 81.

rampitec marked an inline comment as done.Feb 9 2017, 5:23 PM
rampitec added inline comments.
lib/Target/AMDGPU/SIRegisterInfo.cpp
1336–1337

Here, gdb log:

(gdb) p (int)AMDGPU::M0
$9 = 89
(gdb) call TRI->hasRegUnit(AMDGPU::M0, 81)
$12 = true
(gdb) call TRI->hasRegUnit(AMDGPU::M0, 89)
$13 = false
(gdb) call TRI->hasRegUnit(AMDGPU::M0, AMDGPU::M0)
$14 = false
arsenm accepted this revision.Feb 9 2017, 5:26 PM

LGTM with param name fixed

lib/Target/AMDGPU/SIRegisterInfo.cpp
1333

Ditto

lib/Target/AMDGPU/SIRegisterInfo.h
214

Param name is misleading, it should be Reg not RegUnit

This revision is now accepted and ready to land.Feb 9 2017, 5:26 PM
rampitec added inline comments.Feb 9 2017, 5:32 PM
lib/Target/AMDGPU/SIRegisterInfo.h
214

Matt, this is RegUnit. If that would be reg I would not need to call hasRegUnit and just compared register directly. The function is called getRegUnit... and its parent definition has RegUnit argument name.

It is a RegUnit, really ;)

arsenm added inline comments.Feb 9 2017, 5:54 PM
lib/Target/AMDGPU/SIRegisterInfo.h
214

OK, I really hate the RegUnit distinctions. This confusion happens everywhere

This revision was automatically updated to reflect the committed changes.