Skip to content
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

Enhance type analysis #7563

Merged
merged 6 commits into from
Aug 17, 2023
Merged

Enhance type analysis #7563

merged 6 commits into from
Aug 17, 2023

Conversation

bjorng
Copy link
Contributor

@bjorng bjorng commented Aug 15, 2023

Provide type information for frequently used BIFs (such as binary_to_list/1). Also enhance the value range analysis for some of the arithmetic operations.

@bjorng bjorng added team:VM Assigned to OTP team VM enhancement labels Aug 15, 2023
@bjorng bjorng requested a review from jhogberg August 15, 2023 07:03
@bjorng bjorng self-assigned this Aug 15, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Aug 15, 2023

CT Test Results

       2 files     294 suites   11m 4s ⏱️
   779 tests    765 ✔️ 14 💤 0
4 843 runs  4 829 ✔️ 14 💤 0

Results for commit bb4990b.

♻️ 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

  • No CT logs found
  • No HTML docs found
  • No Windows Installer found

// Erlang/OTP Github Action Bot

@bjorng bjorng added the testing currently being tested, tag is used by OTP internal CI label Aug 15, 2023
lib/compiler/src/beam_call_types.erl Outdated Show resolved Hide resolved
lib/compiler/src/beam_call_types.erl Outdated Show resolved Hide resolved
Teach beam_bounds:bound/3 to determine a range for the `div` operator
when nothing is known about the divisor. For example:

    div0(A, B) when is_integer(A), 0 =< A, A < 1204 ->
        %% Range for A is 0..1023
        A div B.                % Range is -1023..1023
Teach beam_bounds:bound/3 to determine a range for the `rem` operator
when nothing is known about the right-hand side operand. For example:

    rem0(A, B) when is_integer(A), 0 =< A, A < 1204 ->
        %% Range for A is 0..1023
        A rem B.                % Range is 0..1023 (same as for A)
Teach beam_bounds:bounds/3 to calculate a range for the `bsl` operator
when the left-hand side operand is partly unbounded. For example:

    bsl0(A) when is_integer(A), A >= 1 ->
        %% Range for A is 1..'+inf'
        A bsl 3.                % Range is 8..'+inf'

    bsl1(A) when is_integer(A), A =< 10 ->
        %% Range for A is '-inf'..10
        A bsl 3.                % Range is '-inf'..80
Teach beam_bounds:bounds/3 to calculate a range for the `bor` operator
for negative or partly unbounded arguments. For example:

    bor0(A) when is_integer(A), -10 =< A, A =< 10 ->
        %% Range for A is -10..10
        A bor 1.                % Range is '-inf'..11

    bor1(A, B) when is_integer(A), A < 0, is_integer(B), B < 0 ->
        %% Range for A and B is '-inf'..-1
        A bor B.                % Range is '-inf'..-1

    bor2(A, B) when is_integer(A), A >= 1, is_integer(B), B >= 10 ->
        %% Range for A is 1..'+inf'; range for B is 10..'+inf'
        A bor B.                % Range is 10..'+inf'
Teach beam_bounds:bound/3 to determine a range for the `*` operator
when both factors have a non-negative lower bound. For example:

    m(A, B) when is_integer(A), A >= 2, is_integer(B), B >= 10 ->
        %% Range for A is 2..'+inf'; range for B is 10..'+inf'
        A * B < 100.            % Range for A * B is 20..'+inf'
@bjorng bjorng force-pushed the bjorn/compiler/types branch 2 times, most recently from bb4990b to c5979b0 Compare August 17, 2023 09:40
@bjorng bjorng merged commit 0a5b4ad into erlang:master Aug 17, 2023
2 checks passed
@bjorng bjorng deleted the bjorn/compiler/types branch August 17, 2023 09:41
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