Skip to content

Conversation

rbrchen
Copy link
Contributor

@rbrchen rbrchen commented Sep 2, 2025

Fix a bug in SSABraun where, in tryRemoveTrivialPhi(), a trivial phi is not removed from its own user list before phi.replaceBy(same, this) is called to replace all users of the trivial phi.

Add five tests to TestSSA: deadCode(), ifelseLoopNested(), violaJones(), binarySearch(), and quicksort(). violaJones() is inspired by the method findFeaturesKernel in HAT kernel ViolaJones.


Progress

  • Change must not contain extraneous whitespace

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/babylon.git pull/542/head:pull/542
$ git checkout pull/542

Update a local copy of the PR:
$ git checkout pull/542
$ git pull https://git.openjdk.org/babylon.git pull/542/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 542

View PR using the GUI difftool:
$ git pr show -t 542

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/babylon/pull/542.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 2, 2025

👋 Welcome back rbrchen! A progress list of the required criteria for merging this PR into code-reflection will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Sep 2, 2025

@rbrchen This change is no longer ready for integration - check the PR body for details.

@openjdk openjdk bot added ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 2, 2025
@mlbridge
Copy link

mlbridge bot commented Sep 2, 2025

Webrevs

@SirYwell
Copy link
Member

SirYwell commented Sep 2, 2025

Hi, it's not obvious to me what the bug is. The replaceBy method has the user == this check; what's the difference to removing itself before? And is the returned list wrong, or why aren't you using it anymore?

@rbrchen
Copy link
Contributor Author

rbrchen commented Sep 2, 2025

Hi! Sorry about the confusion; I just realized this change doesn't actually fix the bug, and that the core of the problem lies in how the maps additionalParameters and loads update.

Your original code in tryRemoveTrivialPhi() was correct, but when a phi is added to additionalParameters and is later replaced by a parameter via replaceBy(), both additionalParameters and loads are not updated to keep track of the new parameter.

I can restore your code and implement those changes to make sure that the two maps replace deleted phis with appropriate values.

@rbrchen rbrchen marked this pull request as draft September 2, 2025 22:04
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 2, 2025
@SirYwell
Copy link
Member

SirYwell commented Sep 3, 2025

Interesting, thanks for the investigation!

A few pointers regarding the mentioned maps:

  • additionalParameters should only need removal at this point, as we don't need a block parameter for the new definition anymore
  • The loads are updated in replaceBy, but there might be cases where things go wrong there
  • There also is deletedPhis, which is supposed to correct lookups to instead look for a definition in the dominating blocks

These are the parts not present in the original algorithm due to (im)mutability, so I always suspected these to be the most fragile parts of the implementation. If you have any ideas to simplify these "workarounds", I'd be very happy :)

@rbrchen
Copy link
Contributor Author

rbrchen commented Sep 3, 2025

Thanks for the pointers! I'll circle back to this PR with any ideas and/or code changes for the maps :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants