-
-
Notifications
You must be signed in to change notification settings - Fork 32k
GH-130415: Narrow str
to ""
based on boolean tests
#130476
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
80c1c6c
Add failing regression test for _TO_BOOL_STR
fluhus 23695d6
Improve test to outsmart JIT
fluhus fcf4116
Add optimization path to _TO_BOOL_STR
fluhus e23b84a
📜🤖 Added by blurb_it.
blurb-it[bot] ab263fe
Correct res type and change `f` var to `empty`
fluhus d5bfcdc
Add Amit Lavon to ACKS
fluhus 601392d
Assign truthiness to empty strings in JIT
fluhus 58884ab
Improve un-proveable empty string in JIT test
fluhus 905d3ef
Merge branch 'main' into hack-night2
brandtbucher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add optimization path to _TO_BOOL_STR
- Loading branch information
commit fcf411621544952cb4224e5eb81b4f41de6f97cd
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
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.
This is strictly incorrect. We don't know that
value
is "" until after the_GUARD_IS_FALSE_POP
.The reason that matters is that when we start attaching type information to side exits, as we probably will in 3.15, then this could lead us to infer that
value
is "" on both branches. Which would be wrong.There are two possible fixes for this.
TO_BOOL_STR
and_GUARD_IS_FALSE_POP/_GUARD_IS_TRUE_POP
into a single (super)instruction, then optimize that.TO_BOOL
with its input, then in_GUARD_IS_FALSE_POP
convert the input value toTO_BOOL
.I prefer the second option, although it may be more work, as it is more flexible and can be extended more easily.
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.
Yeah, @Fidget-Spinner and I suggested something like the latter on the issue (new symbols like
JitBoolOf(JitOptSymbol *source, bool inverted)
andJitEqualTo(JitOptSymbol *lhs, JitOptSymbol *rhs, bool inverted)
). That's probably the direction we're headed in longer term.However, I don't think we should let perfect be the enemy of good here. We have nice, working optimizations in these PRs; just because we might sink info onto side exits in the future probably shouldn't prevent us from making changes like this now for 3.14, which are perfectly correct for the current optimizer (which doesn't sink anything).
I'm inclined to land these changes and other similar ones for
==
/!=
now, and make the symbolic representation of derived boolean values more complex later as an improvement (it will also be able to handle more uncommon cases likex = y == 42; if x: ...
). I'm really worried that if we try to "future-proof" optimizations based on what we could do six months from now, it will prevent actual improvements in the near term.But I'll defer to you here. If having
value
be narrowed one uop too early in the instruction stream is enough to block this PR, I can work with these new contributors on the more complex solution. But as-is, this has no bugs and works as intended. We don't sink value info onto side exits, so it's correct.