Skip to content

[TableGen][SubtargetEmitter] Early exit from loop in FindWriteResources and FindReadAdvance #92202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

michaelmaitland
Copy link
Contributor

@michaelmaitland michaelmaitland commented May 15, 2024

This gives us a 30% speed improvement in our downstream.

@@ -910,6 +910,7 @@ SubtargetEmitter::FindWriteResources(const CodeGenSchedRW &SchedWrite,
ProcModel.ModelName);
}
ResDef = WR;
break;
Copy link
Collaborator

@topperc topperc May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this make the PrintFatalError dead code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I messed up. Need to take a second look at this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have addressed this problem

@michaelmaitland michaelmaitland marked this pull request as draft May 15, 2024 02:15
This gives us a 26% speed improvement in our downstream.
@michaelmaitland michaelmaitland force-pushed the early-exit-find-write-resource branch from d947224 to 3fc1d3e Compare May 15, 2024 17:13
@michaelmaitland michaelmaitland changed the title [TableGen][SubtargetEmitter] Early exit from loop in FindWriteResources [TableGen][SubtargetEmitter] Early exit from loop in FindWriteResources and FindReadAdvance May 15, 2024
@michaelmaitland michaelmaitland force-pushed the early-exit-find-write-resource branch from 3fc1d3e to 3432c73 Compare May 15, 2024 17:17
@michaelmaitland michaelmaitland force-pushed the early-exit-find-write-resource branch from 3432c73 to 6b710d0 Compare May 15, 2024 17:17
@michaelmaitland michaelmaitland marked this pull request as ready for review May 15, 2024 17:18
@michaelmaitland michaelmaitland requested a review from topperc May 15, 2024 17:18
if (!AliasDef && SchedWrite.TheDef == WR->getValueAsDef("WriteType")) {
ResDef = WR;
break;
} else if (AliasDef == WR->getValueAsDef("WriteType")) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No else needed after break

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Copy link

github-actions bot commented May 15, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

// there is no need to verify whether there are resources defined for both
// SchedWrite and its alias.
Record *WRDef = WR->getValueAsDef("WriteType");
if (!AliasDef && SchedWrite.TheDef == WRDef) {
Copy link
Collaborator

@topperc topperc May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if AliasDef is non-null. We won't update ResDef if SchedWrite.TheDef == WRDef.

Suggested change
if (!AliasDef && SchedWrite.TheDef == WRDef) {
Record *WRDef = WR->getValueAsDef("WriteType");
if (AliasDef == WRDef || SchedWrite.TheDef == WRDef) {
if (ResDef)
PrintFatalError...
ResDef = WR;
// If there is no AliasDef and we find a match, we can early exit...
if (!AliasDef)
break;

@michaelmaitland michaelmaitland requested a review from topperc May 15, 2024 17:48
@michaelmaitland michaelmaitland force-pushed the early-exit-find-write-resource branch from 4ffd8fa to 2b6aa35 Compare May 15, 2024 17:52
Copy link
Collaborator

@topperc topperc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@michaelmaitland michaelmaitland merged commit c675a58 into llvm:main May 16, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants