C++: Fix join-order problem in getNextSwitchCase#21765
Merged
jketema merged 4 commits intogithub:mainfrom Apr 28, 2026
Merged
Conversation
Before on `neovim`:
```
[2026-04-28 14:54:20] Evaluated non-recursive predicate Stmt::SwitchCase.getNextSwitchCase/0#dispred#2d3cb6d3@ac8178o2 in 68ms (size: 20848).
Evaluated relational algebra for predicate Stmt::SwitchCase.getNextSwitchCase/0#dispred#2d3cb6d3@ac8178o2 with tuple counts:
21888 ~0% {2} r1 = SCAN switch_case OUTPUT In.2, In.0
21888 ~0% {4} | JOIN WITH #switch_caseMerge_21#join_rhs ON FIRST 1 OUTPUT Lhs.1, Lhs.0, _, Rhs.1
21888 ~4% {3} | REWRITE WITH Tmp.2 := 1, Out.2 := (In.3 - Tmp.2) KEEPING 3
24091916 ~0% {3} | JOIN WITH switch_case ON FIRST 1 OUTPUT Lhs.2, Rhs.2, Lhs.1
20848 ~2% {2} | JOIN WITH #switch_caseMerge_12#join_rhs ON FIRST 2 OUTPUT Lhs.1, Lhs.2
return r1
```
After:
```
[2026-04-28 15:30:53] Evaluated non-recursive predicate Stmt::SwitchCase.getNextSwitchCase/0#dispred#2d3cb6d3@bf9801oj in 0ms (size: 20848).
Evaluated relational algebra for predicate Stmt::SwitchCase.getNextSwitchCase/0#dispred#2d3cb6d3@bf9801oj with tuple counts:
21888 ~0% {4} r1 = SCAN switch_case OUTPUT In.0, _, In.2, In.1
21888 ~1% {3} | REWRITE WITH Tmp.1 := 1, Out.1 := (In.3 + Tmp.1) KEEPING 3
20848 ~2% {2} | JOIN WITH switch_case ON FIRST 2 OUTPUT Lhs.2, Rhs.2
return r1
```
IdrissRio
requested changes
Apr 28, 2026
| * break; | ||
| * } | ||
| * ``` | ||
| * 0 yields `case 5:`, 1 yields `case 6:`, and 2 yields `default:`. |
Contributor
There was a problem hiding this comment.
Suggested change
| * 0 yields `case 5:`, 1 yields `case 6:`, and 2 yields `default:`. | |
| * 0 yields `case 1:`, 1 yields `case 2:`, and 2 yields `default:`. |
Contributor
Author
There was a problem hiding this comment.
Fixed by updating the example instead.
Contributor
Author
|
DCA looks good. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See individual commit messages for further details.