perf(codegen): a truthiness test asks a loop region for no Number lane - #11856
Merged
Merged
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (4)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Fixes the #10495
own3regression that #11795 introduced.Cause
#11795 admits a loop region whose Number reads (R) fall on non-identity lanes and tests their values on every guard. Both of the region's R collectors counted a value that is only tested for truthiness as a Number operand:
number_operand_reads, and the accumulator value flowregion_number_flow_reads. Ina += (o.$L ? 1 : 0) + (o.$d ? 1 : 0) + …they requested R foro.$L, a string. The learned word carried the value test, which failed on every iteration, so the loop paid the guard and then the generic path (227 to 246 instructions per op).Fix
A conditional's test and a
!operand are not Number operands. The conditional's arms are still values. Both collectors skip the test and the!operand.Results (instructions per op)
Real workloads (n=5, median instructions:u; main = 5b06d69)
Outputs are identical to main's in every run.
Verification
a_truthiness_test_requests_no_number_lane: R mask 0 and no value test forh += o.x ? 1 : 0andh += !o.x ? 1 : 0. Control:h += n ? o.x : 0still requests R.