-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Ruby: Split basic blocks around constant conditionals #11153
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
Conversation
aibaars
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
| if x or y then | ||
| foo | ||
| else | ||
| foo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use a different name in the else clause to make it easier to validate the expected output.
| foo | |
| bar |
| foo | ||
| end | ||
|
|
||
| if x or y then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add a test case for and and perhaps not as well.
|
@aibaars : Comments addressed, and DCA looks fine. |
aibaars
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.