Skip to content

LoopRotate: remove redundant phis after ssa-update #78136

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 5 commits into from
Dec 12, 2024

Conversation

eeckstein
Copy link
Contributor

This is needed after running the SSAUpdater in loop-rotate, because the updater can insert unnecessary phis in the middle of the original liverange of a value which breaks up the original liverange into smaller ones:

   %1 = def_of_owned_value
   %2 = begin_borrow %1
   ...
   br bb2(%1)
 bb2(%3 : @owned $T): // inserted by SSAUpdater
   ...
   end_borrow %2      // use after end-of-lifetime!
   destroy_value %3

Fixes an ownership error.

Also, remove the replace-arg-with-struct peephole optimization from loop-rotate. It not belong to loop-rotate and does not work with OSSA. This peephole is covered by other optimizations.

This does not belong to loop-rotate and does not work with OSSA.
This peephole is covered by other optimizations.
To be able to use `!=` for operands.
…lues if all incoming values are the same

This is needed after running the SSAUpdater for an existing OSSA value, because the updater can
insert unnecessary phis in the middle of the original liverange which breaks up the original
liverange into smaller ones:

```
   %1 = def_of_owned_value
   %2 = begin_borrow %1
   ...
   br bb2(%1)
 bb2(%3 : @owned $T): // inserted by SSAUpdater
   ...
   end_borrow %2      // use after end-of-lifetime!
   destroy_value %3
```

It's not needed to run this utility if SSAUpdater is used to create a _new_ OSSA liverange.
Because it now has the replacePhisWithIncomingValues utility, which works for all kind of phis.
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein
Copy link
Contributor Author

@swift-ci benchmark

Copy link
Contributor

@meg-gupta meg-gupta left a comment

Choose a reason for hiding this comment

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

LGTM

@eeckstein eeckstein merged commit 0c860f8 into swiftlang:main Dec 12, 2024
6 checks passed
@eeckstein eeckstein deleted the fix-ssa-updater-2 branch December 12, 2024 19:59
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