This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU][NFC] Refine representation of register intervals in SIInsertWaitcnts.
Changes PlannedPublic

Authored by kosarev on Aug 4 2023, 5:47 AM.

Details

Summary

Currently, we represent register intervals as pairs of corresponding encoding values. The main idea behind this this patch is to replace such pairs with structures that represent the intervals in a more abstract way, thus conceptually separating the encoding details from the rest of the logic in the pass.

The new structures are still essentially pairs of integers representing the interval boundaries, but now make no references to encodings and have more suitably named fields. Using the chance, the type of endpoints was changed to unsigned to match the types of values they are compared against. The interval structures were also made iterable to simplify the code.

Diff Detail

Unit TestsFailed

Event Timeline

kosarev created this revision.Aug 4 2023, 5:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2023, 5:47 AM
kosarev requested review of this revision.Aug 4 2023, 5:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2023, 5:47 AM
foad added a comment.Aug 4 2023, 6:28 AM

Can you please say more than "Refine" in the description? What's the point of this? Why is it better? I don't want to have to read the whole patch to try to guess the answers for myself.

kosarev updated this revision to Diff 547285.Aug 4 2023, 11:22 AM

Update the commit description.

kosarev edited the summary of this revision. (Show Details)Aug 4 2023, 11:23 AM

Sorry, that's unintentionally!

foad added a comment.Aug 7 2023, 6:33 AM

Currently, we represent register intervals as pairs of corresponding encoding values. The main idea behind this this patch is to replace such pairs with structures that represent the intervals in a more abstract way, thus conceptually separating the encoding details from the rest of the logic in the pass.

The new structures are still essentially pairs of integers representing the interval boundaries, but now make no references to encodings and have more suitably named fields.

Personally I don't see much benefit to the "make no references to encodings" abstraction unless you are planning to change things, such that the interval endpoints are no longer register encoding values. Are you?

Using the chance, the type of endpoints was changed to unsigned to match the types of values they are compared against.

Sure, seems nice, and it looks like {0, 0} works naturally as a placeholder so there was no need for the old code to use {-1, -1}.

The interval structures were also made iterable to simplify the code.

That is nice.

Personally I don't see much benefit to the "make no references to encodings" abstraction unless you are planning to change things, such that the interval endpoints are no longer register encoding values. Are you?

I don't know about much benefit, but think there is some. As the pass only really uses encodings as implementation detail of how register operands are translated to intervals, segregating everything related to them in a small function simplifies the conceptual picture to readers of this code. It also encourages using that new translation function instead of replicating code that retrieves and manipulates encodings directly, which as any other deduplication might be considered a good thing regardless of anticipated changes.

kosarev planned changes to this revision.Aug 10 2023, 2:24 AM

Let's postpone this until the benefit is more obvious.