Skip to content

Conversation

@meg-gupta
Copy link
Contributor

copy_value is marked as having no side effects.
Teach LoopRotate to avoid moving it to the pre header and instead duplicate it while rotating the loop.

copy_value is marked as having no side effects.
Teach LoopRotate to avoid moving it to the pre header and instead duplicate it while rotating the loop.
@meg-gupta
Copy link
Contributor Author

@swift-ci test

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

How does loop rotate handle other instructions which "may retain"?
Isn't copy_value considered to have a "retain" side effect? If not, that seems like a bigger bug.

@meg-gupta
Copy link
Contributor Author

LoopRotate looks for mayHaveSideEffects - https://github.com/apple/swift/blob/5b9aef91f8e96dcc82ac3828c18fa26473d17fe6/lib/SILOptimizer/LoopTransforms/LoopRotate.cpp#L116

copy_value is marked as having no side effects

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

Meghana pointed out that in copy_value is not actually supposed to have side effects. I think this change is fine and we can discuss how to move forward in parallel

@atrick
Copy link
Contributor

atrick commented Dec 6, 2022

@eeckstein Here's the issue:

In OSSA copy_value does not have any side-effects for the purpose of deleting the instruction or moving code around the instructions. As long as the OSSA constraints still hold-up, those transformations are legal. So, in that sense "may-retain" is false. But for the purpose of hoisting/sinking the copy_value itself, it does perform a retain. So in that sense, "may-retain" is true. Any idea how we want to model this kind of side-effect going forward?

@meg-gupta meg-gupta merged commit 9774e98 into swiftlang:main Dec 6, 2022
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