diff options
author | Björn Gustavsson <[email protected]> | 2018-05-07 10:30:22 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2018-05-07 10:30:22 +0200 |
commit | 7a19de1bf0eb863e0d0febf7e7e5e555c8628575 (patch) | |
tree | 84331df750b98d76b59472ecf2de657121798931 /lib/compiler/src/beam_dead.erl | |
parent | 49dc5d3975357971ffc3020d095a8187d80e3b69 (diff) | |
parent | 5d0874a8f9fd617308d9024783db1e4e24268184 (diff) | |
download | otp-7a19de1bf0eb863e0d0febf7e7e5e555c8628575.tar.gz otp-7a19de1bf0eb863e0d0febf7e7e5e555c8628575.tar.bz2 otp-7a19de1bf0eb863e0d0febf7e7e5e555c8628575.zip |
Merge pull request #1802 from michalmuskala/map-is-key-bif
Introduce is_map_key/2 guard BIF
OTP-15037
Diffstat (limited to 'lib/compiler/src/beam_dead.erl')
-rw-r--r-- | lib/compiler/src/beam_dead.erl | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/compiler/src/beam_dead.erl b/lib/compiler/src/beam_dead.erl index dbbaae05eb..762c7bdf9e 100644 --- a/lib/compiler/src/beam_dead.erl +++ b/lib/compiler/src/beam_dead.erl @@ -392,6 +392,26 @@ backward([{bif,'or',{f,To0},[Dst,{atom,false}],Dst}=I|Is], D, _ -> backward(Is, D, [I|Acc]) end; +backward([{bif,map_get,{f,FF},[Key,Map],_}=I0, + {test,has_map_fields,{f,FT}=F,[Map|Keys0]}=I1|Is], D, Acc) when FF =/= 0 -> + case shortcut_label(FF, D) of + FT -> + case lists:delete(Key, Keys0) of + [] -> + backward([I0|Is], D, Acc); + Keys -> + Test = {test,has_map_fields,F,[Map|Keys]}, + backward([Test|Is], D, [I0|Acc]) + end; + _ -> + backward([I1|Is], D, [I0|Acc]) + end; +backward([{bif,map_get,{f,FF},[_,Map],_}=I0, + {test,is_map,{f,FT},[Map]}=I1|Is], D, Acc) when FF =/= 0 -> + case shortcut_label(FF, D) of + FT -> backward([I0|Is], D, Acc); + _ -> backward([I1|Is], D, [I0|Acc]) + end; backward([I|Is], D, Acc) -> backward(Is, D, [I|Acc]); backward([], _D, Acc) -> Acc. |