This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Enable merging m0 initializations.
ClosedPublic

Authored by kerbowa on Jul 15 2019, 1:27 PM.

Details

Summary

Enable hoisting and merging m0 defs that are initialized with the
same immediate value. Fixes bug where removed instructions are
not consider to interfere with other inits, and make sure to not
host inits before block prologs.

Diff Detail

Repository
rL LLVM

Event Timeline

kerbowa created this revision.Jul 15 2019, 1:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 15 2019, 1:27 PM
rampitec added inline comments.Jul 15 2019, 1:38 PM
llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
510 ↗(On Diff #209940)

Source alignment is off.

llvm/test/CodeGen/AMDGPU/merge-m0.mir
149 ↗(On Diff #209940)

Most of these attributes can be removed.

arsenm added inline comments.Jul 15 2019, 1:41 PM
llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
458–459 ↗(On Diff #209940)

Why does this need to care about the prolog instructions? (FYI I'm planning on eliminating the rarely followed concept)

rampitec added inline comments.Jul 15 2019, 2:02 PM
llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
458–459 ↗(On Diff #209940)

You actually cannot, it was created to prevent RA from insrting spills into endif/else block before we updated exec mask.

arsenm added inline comments.Jul 15 2019, 2:05 PM
llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
458–459 ↗(On Diff #209940)

Yes, I'm working on splitting the blocks to avoid this

rampitec added inline comments.Jul 15 2019, 2:12 PM
llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
458–459 ↗(On Diff #209940)

I never found a way to properly split a block for that. Assume you split it and endif sequence is in the 1st block. What would prevent RA from inserting spill/restore there? You will need to mark a whole block as not suitable for spills and in addition prohibit RA from inserting any COPY instructions there.

Besides until there is another way m0 init must follow prologue anyway. If it is inserted before endif sequence that will break a contiguous sequence of prologue instructions and we will have bogus spilling again.

kerbowa updated this revision to Diff 209956.Jul 15 2019, 2:28 PM

Fix indent, prolog->prologue, match increment style, remove attributes from test.

kerbowa marked 2 inline comments as done.Jul 15 2019, 2:30 PM
arsenm added inline comments.Jul 15 2019, 2:31 PM
llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
458–459 ↗(On Diff #209940)

The details of the split aren't important here. Why does this scalar value initialization care?

kerbowa updated this revision to Diff 209959.Jul 15 2019, 2:37 PM

Update test.

rampitec added inline comments.Jul 15 2019, 2:48 PM
llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
458–459 ↗(On Diff #209940)

It does not care itself. But if inserted it will break prologue, allowing to insert a spill right before it.

This revision is now accepted and ready to land.Jul 15 2019, 2:50 PM
This revision was automatically updated to reflect the committed changes.