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 /lib/compiler/test/Makefile | |
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 'lib/compiler/test/Makefile')
-rw-r--r-- | lib/compiler/test/Makefile | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/compiler/test/Makefile b/lib/compiler/test/Makefile index 6553d10077..0cd8618730 100644 --- a/lib/compiler/test/Makefile +++ b/lib/compiler/test/Makefile @@ -11,6 +11,7 @@ MODULES= \ beam_validator_SUITE \ beam_disasm_SUITE \ beam_except_SUITE \ + beam_type_SUITE \ beam_utils_SUITE \ bs_bincomp_SUITE \ bs_bit_binaries_SUITE \ @@ -43,6 +44,7 @@ NO_OPT= \ andor \ apply \ beam_except \ + beam_type \ beam_utils \ bs_construct \ bs_match \ |