Conversation
`jit_ADD_OFFSET()` created the offset through `jit_CONST_ADDR()`, which
returns a unique (non-interned) constant. IR's own folding of nested
offsets, `ADD(ADD(x, c1), c2)`, creates an interned constant for `c1+c2`.
The same address can therefore end up with two different offset
refs, and CSE and store-to-load forwarding, which both need an
identical address ref, miss it.
The uniqueing exists likely for the exit addresses mostly, but for
offsets this is wrong.
For example, the type store and the type load of the same zval end up
with different refs:
```php
function count_big($n) {
$c = 0;
for ($i = 0; $i < $n; $i++) {
$big = $i > 5;
if ($big) {
$c++;
}
}
return $c;
}
```
Loop body before:
```asm
movl %esi, 0x88(%r14)
cmpb $3, 0x88(%r14)
jne jit$$trace_exit_4
```
After:
```asm
movl %esi, 0x88(%r14)
cmpb $3, %sil ; no reload
jne jit$$trace_exit_4
```
In general, more redundant loads can be avoided, and in some cases type
guards can be eliminated due to store->load forwarding.
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.
jit_ADD_OFFSET()created the offset throughjit_CONST_ADDR(), which returns a unique (non-interned) constant. IR's own folding of nested offsets,ADD(ADD(x, c1), c2), creates an interned constant forc1+c2. The same address can therefore end up with two different offset refs, and CSE and store-to-load forwarding, which both need an identical address ref, miss it.The uniqueing exists likely for the exit addresses mostly, but for offsets this is wrong.
For example, the type store and the type load of the same zval end up with different refs:
Loop body before:
After:
In general, more redundant loads can be avoided, and in some cases type guards can be eliminated due to store->load forwarding.