Ruby: Split basic blocks around constant conditionals#11153
Merged
hvitved merged 3 commits intogithub:mainfrom Nov 8, 2022
Merged
Ruby: Split basic blocks around constant conditionals#11153hvitved merged 3 commits intogithub:mainfrom
hvitved merged 3 commits intogithub:mainfrom
Conversation
aibaars
reviewed
Nov 8, 2022
| if x or y then | ||
| foo | ||
| else | ||
| foo |
Contributor
There was a problem hiding this comment.
Let's use a different name in the else clause to make it easier to validate the expected output.
Suggested change
| foo | |
| bar |
| foo | ||
| end | ||
|
|
||
| if x or y then |
Contributor
There was a problem hiding this comment.
Also add a test case for and and perhaps not as well.
Contributor
Author
|
@aibaars : Comments addressed, and DCA looks fine. |
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.
In cases such as
we have a CFG that looks like
graph TD; xvar(x); yvar(y); foo(foo); bar(bar); orfalse("or [false]"); ortrue("or [true]"); xvar-- false -->yvar; xvar-- true -->ortrue; yvar-- false -->orfalse; yvar-- true -->ortrue; ortrue-- true -->foo; orfalse-- false -->bar;In order to record the fact that
x or ytrue-controlsfoo(resp.false-controlsbar), we need to make sure that a new basic block is started at bothfooandbar; that is, we split the existing basic blocks into two.