diff options
author | Björn Gustavsson <[email protected]> | 2012-12-06 14:13:41 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2012-12-06 14:13:41 +0100 |
commit | 5b40d5502f008f9c44bc4a3bd9037439e35ce0a7 (patch) | |
tree | 2dcc22b52d74b73b08d129d98c8afc541634600e /lib/compiler/test | |
parent | 1f1818d49ccb5bf1a04fadace100a3e3cf95b52f (diff) | |
parent | c38a6726500cd726dd3e605b3be389ee96df131c (diff) | |
download | otp-5b40d5502f008f9c44bc4a3bd9037439e35ce0a7.tar.gz otp-5b40d5502f008f9c44bc4a3bd9037439e35ce0a7.tar.bz2 otp-5b40d5502f008f9c44bc4a3bd9037439e35ce0a7.zip |
Merge branch 'bjorn/compiler/minor-optimization-polishing/OTP-10193'
* bjorn/compiler/minor-optimization-polishing/OTP-10193:
beam_bsm: Improve handling of bs_start_match2 instructions
beam_utils: Improve is_not_used/3 for bit syntax matching
beam_bsm: Make the optimization applicable in more circumstances
beam_jump: Move bs_context_to_binary/1 + exit instruction
Diffstat (limited to 'lib/compiler/test')
-rw-r--r-- | lib/compiler/test/bs_match_SUITE.erl | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/lib/compiler/test/bs_match_SUITE.erl b/lib/compiler/test/bs_match_SUITE.erl index e8f5c55c1a..d63d2235d7 100644 --- a/lib/compiler/test/bs_match_SUITE.erl +++ b/lib/compiler/test/bs_match_SUITE.erl @@ -33,7 +33,7 @@ matching_meets_construction/1,simon/1,matching_and_andalso/1, otp_7188/1,otp_7233/1,otp_7240/1,otp_7498/1, match_string/1,zero_width/1,bad_size/1,haystack/1, - cover_beam_bool/1,matched_out_size/1]). + cover_beam_bool/1,matched_out_size/1,follow_fail_branch/1]). -export([coverage_id/1,coverage_external_ignore/2]). @@ -57,7 +57,7 @@ groups() -> matching_meets_construction,simon, matching_and_andalso,otp_7188,otp_7233,otp_7240, otp_7498,match_string,zero_width,bad_size,haystack, - cover_beam_bool,matched_out_size]}]. + cover_beam_bool,matched_out_size,follow_fail_branch]}]. init_per_suite(Config) -> @@ -1108,6 +1108,32 @@ mos_bin(<<L,Bin:L/binary,"abcdefghij">>) -> L = byte_size(Bin), Bin. +follow_fail_branch(_) -> + 42 = ffb_1(<<0,1>>, <<0>>), + 8 = ffb_1(<<0,1>>, [a]), + 42 = ffb_2(<<0,1>>, <<0>>, 17), + 8 = ffb_2(<<0,1>>, [a], 0), + ok. + +ffb_1(<<_,T/bitstring>>, List) -> + case List of + <<_>> -> + 42; + [_|_] -> + %% The fail branch of the bs_start_match2 instruction + %% pointing to here would be ignored, making the compiler + %% incorrectly assume that the delayed sub-binary + %% optimization was safe. + bit_size(T) + end. + +ffb_2(<<_,T/bitstring>>, List, A) -> + case List of + <<_>> when A =:= 17 -> 42; + [_|_] -> bit_size(T) + end. + + check(F, R) -> R = F(). |