Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
5131-Derive-ranges-from-matching-of-signed-inte...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 5131-Derive-ranges-from-matching-of-signed-integer-segmen.patch of Package erlang
From 6ffcc0950307198882b8ac9ebc821a21de3dffeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Wed, 9 Feb 2022 08:33:10 +0100 Subject: [PATCH 1/2] Derive ranges from matching of signed integer segments Derive ranges from matching of signed integer segments using the binary syntax. --- lib/compiler/src/beam_ssa_type.erl | 7 ++++--- lib/compiler/src/beam_validator.erl | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/compiler/src/beam_ssa_type.erl b/lib/compiler/src/beam_ssa_type.erl index 00b5f6db1e..487f793151 100644 --- a/lib/compiler/src/beam_ssa_type.erl +++ b/lib/compiler/src/beam_ssa_type.erl @@ -2208,12 +2208,13 @@ bs_match_type(integer, Args) -> #b_literal{val=Size}, #b_literal{val=Unit}] when Size * Unit < 64 -> NumBits = Size * Unit, + Max = (1 bsl NumBits) - 1, case member(unsigned, Flags) of true -> - beam_types:make_integer(0, (1 bsl NumBits)-1); + beam_types:make_integer(0, Max); false -> - %% Signed integer. Don't bother. - #t_integer{} + Min = -(Max + 1), + beam_types:make_integer(Min, Max) end; [_|_] -> #t_integer{} diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl index 11f328b470..74b057e903 100644 --- a/lib/compiler/src/beam_validator.erl +++ b/lib/compiler/src/beam_validator.erl @@ -965,11 +965,18 @@ vi({test,bs_get_integer2=Op,{f,Fail},Live, NumBits = Unit * Sz, Stride = NumBits, - Type = case member(unsigned, Flags) of - true when 0 =< NumBits, NumBits =< 64 -> - beam_types:make_integer(0, (1 bsl NumBits)-1); - _ -> - %% Signed integer, way too large, or negative size. + Type = if + 0 =< NumBits, NumBits =< 64 -> + Max = (1 bsl NumBits) - 1, + case member(unsigned, Flags) of + true -> + beam_types:make_integer(0, Max); + false -> + Min = -(Max + 1), + beam_types:make_integer(Min, Max) + end; + true -> + %% Way too large or negative size. #t_integer{} end, -- 2.34.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor