Skip to content
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

inference: Fix correctness and ensure termination in the presence of PhiNodes #53876

Merged
merged 1 commit into from
Mar 28, 2024

Conversation

Keno
Copy link
Member

@Keno Keno commented Mar 27, 2024

There's two related, but distinct, issues here:

  1. We were not using tmerge for merging SSA results inside loops, which could cause infinite looping. In the absence of PhiNodes, things usually have to go through a slot to be able to make the round trip, which would usually put a PhiNode on the path, but it's possible there may be other ways to smuggle things around (e.g. through exception handling).

  2. We were not properly accounting for the fact that PhiNode uses do not need to be linearly ordered in the same BB, so we were getting the type of the testcase here incorrect by failing to re-schedule the PhiNode.

The first of these shows up in the Diffractor test suite, the second was found by writing the test case.

@vtjnash
Copy link
Member

vtjnash commented Mar 27, 2024

I don't think SSAValue was intended to contribute anything towards convergence, so doing so just slightly slows inference and maybe worsens the quality. But PHINodes certainly would need to be implemented to handle convergence just like a Slot.

@vtjnash vtjnash added needs nanosoldier run This PR should have benchmarks run on it compiler:inference Type inference labels Mar 27, 2024
@Keno
Copy link
Member Author

Keno commented Mar 27, 2024

Ok, I can move this handling to PhiNode, which is probably the proper place for it. It's possible similar handling will be required for some of the exception propagation stuff, but let's cross that particular bridge if it comes up.

…PhiNodes

There's two related, but distinct, issues here:
1. We were not using `tmerge` for merging SSA results inside loops,
   which could cause infinite looping. In the absence of PhiNodes, things
   usually have to go through a slot to be able to make the round trip,
   which would usually put a PhiNode on the path, but it's possible there
   may be other ways to smuggle things around (e.g. through exception handling).

2. We were not properly accounting for the fact that PhiNode uses do not need to
   be linearly ordered in the same BB, so we were getting the type of the testcase
   here incorrect by failing to re-schedule the PhiNode.

The first of these shows up in the Diffractor test suite, the second was found
by writing the test case.
@Keno
Copy link
Member Author

Keno commented Mar 27, 2024

@nanosoldier runbenchmarks("inference", vs=":master")

@vtjnash
Copy link
Member

vtjnash commented Mar 27, 2024

Yes, I think this seems right

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

@Keno
Copy link
Member Author

Keno commented Mar 27, 2024

@nanosoldier runbenchmarks("inference", vs=":master")

I don't entirely trust that result. Let me make sure it reproduces.

@Keno
Copy link
Member Author

Keno commented Mar 27, 2024

@nanosoldier runbenchmarks("inference", vs=":master")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - no performance regressions were detected. A full report can be found here.

@Keno Keno removed the needs nanosoldier run This PR should have benchmarks run on it label Mar 28, 2024
@Keno Keno merged commit e07c0f1 into master Mar 28, 2024
8 of 9 checks passed
@Keno Keno deleted the kf/phinodeinfloop branch March 28, 2024 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:inference Type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants