Skip to content

JIT/AArch64: Use 'tbnz/tbz' to check the signedness - #7123

Merged
shqking merged 2 commits into
php:masterfrom
shqking:use-tbnz
Jun 9, 2021
Merged

shqking merged 2 commits into
php:masterfrom
shqking:use-tbnz

Conversation

@shqking

@shqking shqking commented Jun 9, 2021 •

Copy link
Copy Markdown
Contributor

'tbnz/tbz' instruction can be used to check whether a given W or X
register value is negative or positive.

For example,
tst x0, x0; blt >1
can be optimized as tbnz x0, #63, >1

It's important to note that the jump range of 'tbnz/tbz' is limited, and
it's better NOT to use 'tbnz/tbz' if the target of 'b.cond' is a label
in section .cold_code or a global label, such as the instruction
sequence tst RETVALw, RETVALw; blt ->trace_halt at function
zend_jit_trace_exit_stub(), and the instruction sequence tst REG0, REG0; blt >7 at function zend_jit_incdec_obj().

Minor updates:
Use macros BW_OP_32_WITH_CONST and GC_ADDREF at function
zend_jit_push_call_frame().

Test: all ~4k .phpt test cases under tests/ Zend/tests/ ext/opcache/tests/jit/ can pass for Linux JIT/arm64.
Note that in total 8 JIT variants are tested, covering ZTS/nonZTS, HYBRID/VM, and functional/tracing JIT.

Change-Id: I1597609bdabf55ea2f9d24528e7a037bc3e5c3a1

'tbnz/tbz' instruction can be used to check whether a given W or X
register value is negative or positive.

For example,
    ```
    tst x0, x0
    blt >1
    ```
can be optimized as `tbnz x0, php#63, >1`

It's important to note that the jump range of 'tbnz/tbz' is limited, and
it's better NOT to use 'tbnz/tbz' if the target of 'b.cond' is a label
in section .cold_code or a global label, such as the instruction
sequence `tst RETVALw, RETVALw; blt ->trace_halt` at function
zend_jit_trace_exit_stub(), and the instruction sequence `tst REG0,
  REG0; blt >7` at function zend_jit_incdec_obj().

Minor updates:
Use macros BW_OP_32_WITH_CONST and GC_ADDREF at function
zend_jit_push_call_frame().

Change-Id: I1597609bdabf55ea2f9d24528e7a037bc3e5c3a1
@shqking
shqking merged commit ac80aeb into php:master Jun 9, 2021
@shqking
shqking deleted the use-tbnz branch June 9, 2021 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants