Skip to content

Fix loop rotate when header has instructions producing ownership results #79476

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
merged 1 commit into from
Feb 20, 2025

Conversation

meg-gupta
Copy link
Contributor

@meg-gupta meg-gupta commented Feb 18, 2025

LoopRotate currently should avoid moving instructions that produce ownership results to the loop header. Such instructions may have uses with the loop that cannot be moved to the loop header causing over consume ownership verifier errors.

rdar://145086395

@meg-gupta
Copy link
Contributor Author

Extracted bug fix from #79198

@meg-gupta
Copy link
Contributor Author

@swift-ci test

@meg-gupta meg-gupta marked this pull request as ready for review February 19, 2025 00:26
@meg-gupta meg-gupta requested a review from eeckstein as a code owner February 19, 2025 00:26
@meg-gupta
Copy link
Contributor Author

@swift-ci test

@meg-gupta
Copy link
Contributor Author

@swift-ci test Linux platform

2 similar comments
@meg-gupta
Copy link
Contributor Author

@swift-ci test Linux platform

@meg-gupta
Copy link
Contributor Author

@swift-ci test Linux platform

@eeckstein
Copy link
Contributor

@swift-ci apple silicon benchmark

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm!
Let's make sure nothing bad happens to the benchmarks before merging.

@meg-gupta
Copy link
Contributor Author

meg-gupta commented Feb 20, 2025

------- Performance (arm64): -O -------

REGRESSION                      OLD       NEW     DELTA    RATIO    
Set.subtracting.Seq.Empty.Box   58.542    81.04   +38.4%   **0.72x (?)**
COWTree                         864.615   952.0   +10.1%   **0.91x (?)**

------- Code size: -O -------

------- Performance (arm64): -Osize -------

REGRESSION                  OLD       NEW      DELTA    RATIO    
ArrayAppendGenericStructs   881.538   1135.0   +28.8%   **0.78x (?)**

IMPROVEMENT                 OLD       NEW      DELTA    RATIO    
ArrayOfGenericRef           655.0     596.25   -9.0%    **1.10x (?)**

------- Code size: -Osize -------

------- Performance (arm64): -Onone -------

IMPROVEMENT                 OLD        NEW       DELTA    RATIO    
ArrayAppendGenericStructs   1187.778   740.625   -37.6%   **1.60x (?)**

------- Code size: -swiftlibs -------

I don't see any meaningful change here.

Note that we are not avoiding LoopRotate in cases where the header has instructions producing ownership results. We are only avoiding hoisting them when they have invariant operands, LoopRotate can still duplicate such instructions provided it doesn't exceed the threshold.

Merging to fix issue.

@meg-gupta meg-gupta merged commit 653925b into swiftlang:main Feb 20, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants