Skip to content

JIT: Optimise common combinations of relational operators#6025

Merged
bjorng merged 3 commits into
erlang:masterfrom
bjorng:bjorn/jit/optimize-range-check
May 30, 2022
Merged

JIT: Optimise common combinations of relational operators#6025
bjorng merged 3 commits into
erlang:masterfrom
bjorng:bjorn/jit/optimize-range-check

Conversation

@bjorng

@bjorng bjorng commented May 27, 2022

Copy link
Copy Markdown
Contributor

Optimise the generated code for common combinations of relational operators such as in the following examples:

f(A) when is_integer(A), 0 =< A, A =< 1000 ->
    A + 1.

g(A) when 0 =< A, A =< 1000 ->
    A + 1.

@bjorng bjorng added team:VM Assigned to OTP team VM enhancement testing currently being tested, tag is used by OTP internal CI labels May 27, 2022
@bjorng
bjorng requested review from garazdawi and jhogberg May 27, 2022 05:37
@bjorng bjorng self-assigned this May 27, 2022
@github-actions

github-actions Bot commented May 27, 2022

Copy link
Copy Markdown
Contributor

CT Test Results

       4 files     367 suites   43m 49s ⏱️
2 009 tests 1 956 ✔️ 53 💤 0
5 573 runs  5 502 ✔️ 71 💤 0

Results for commit 439bdea.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

bjorng added 3 commits May 30, 2022 04:11
This is not an optimization in itself but it reduces the number
of permutations of adjacent relational operators and thus will
simplify instruction combination optimizations for the JIT.
The `cmp_arg()` helper would generate an unnecessary move to the
SUPER_TMP register if the RHS argument was an X register backed by a
CPU register. For example:

    mov x14, x27
    cmp x26, x14

This code can be simplified to:

    cmp x26, x27
Optimize the generation of native code for common combinations of
relational operators in guards.
@bjorng
bjorng force-pushed the bjorn/jit/optimize-range-check branch from 439bdea to f8a9ccd Compare May 30, 2022 02:13
@bjorng
bjorng merged commit 692a485 into erlang:master May 30, 2022
@bjorng
bjorng deleted the bjorn/jit/optimize-range-check branch May 30, 2022 02:14
@itssundeep itssundeep mentioned this pull request Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants