diff options
author | Björn Gustavsson <[email protected]> | 2015-09-23 07:23:15 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-09-28 10:26:39 +0200 |
commit | c0c5943c3a2646a3383d974c2a1afcff8c5d16d3 (patch) | |
tree | b0e7ab5d8c7aa77aadc14944703922c9f6a6edba /otp_versions.table | |
parent | ae125a3bc62c2165a9db028e12aa6e9f90c7d9cf (diff) | |
download | otp-c0c5943c3a2646a3383d974c2a1afcff8c5d16d3.tar.gz otp-c0c5943c3a2646a3383d974c2a1afcff8c5d16d3.tar.bz2 otp-c0c5943c3a2646a3383d974c2a1afcff8c5d16d3.zip |
beam_type: Improve optimization by keeping track of integers
The ASN.1 compiler often generates code similar to:
f(<<0:1,...>>) -> ...;
f(<<1:1,...>>) -> ....
Internally that will be rewritten to (conceptually):
f(<<B:1,Tail/binary>>) ->
case B of
0 ->
case Tail of ... end;
1 ->
case Tail of ... end;
_ ->
error(case_clause)
end.
Since B comes from a bit field of one bit, we know that the only
possible values are 0 and 1. Therefore the error clause can be
eliminated like this:
f(<<B:1,Tail/binary>>) ->
case B of
0 ->
case Tail of ... end;
_ ->
case Tail of ... end
end.
Similarly, we can also a deduce the range for an integer from
a 'band' operation with a literal integer.
While we are at it, also add a test case to improve the coverage.
Diffstat (limited to 'otp_versions.table')
0 files changed, 0 insertions, 0 deletions