diff options
author | Erlang/OTP <otp@erlang.org> | 2023-05-04 17:25:04 +0200 |
---|---|---|
committer | Erlang/OTP <otp@erlang.org> | 2023-05-04 17:25:04 +0200 |
commit | d754f32cceeecf416878e7d61ee38d921bbbb259 (patch) | |
tree | 05444c80c71b4b55b132ab4d3a8983af87266377 /lib/compiler/src/beam_ssa.erl | |
parent | 5612d3d5fedda6822f7d08beacdecc12993cbf0d (diff) | |
parent | e5f3fea6dbcdf41d5c6d4c00a7d1c85817cf4c01 (diff) | |
download | erlang-d754f32cceeecf416878e7d61ee38d921bbbb259.tar.gz |
Merge branch 'bjorn/compiler/beam_validator/25/GH-7147/OTP-18565' into maint-25
* bjorn/compiler/beam_validator/25/GH-7147/OTP-18565:
Fix two type-related bugs
Diffstat (limited to 'lib/compiler/src/beam_ssa.erl')
-rw-r--r-- | lib/compiler/src/beam_ssa.erl | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/compiler/src/beam_ssa.erl b/lib/compiler/src/beam_ssa.erl index 5037811614..c1d11c89da 100644 --- a/lib/compiler/src/beam_ssa.erl +++ b/lib/compiler/src/beam_ssa.erl @@ -372,13 +372,22 @@ successors(#b_blk{last=Terminator}) -> -spec normalize(b_set() | terminator()) -> b_set() | terminator(). -normalize(#b_set{op={bif,Bif},args=Args}=Set) -> +normalize(#b_set{anno=Anno0,op={bif,Bif},args=Args}=Set) -> case {is_commutative(Bif),Args} of - {false,_} -> - Set; - {true,[#b_literal{}=Lit,#b_var{}=Var]} -> - Set#b_set{args=[Var,Lit]}; - {true,_} -> + {true, [#b_literal{}=Lit,#b_var{}=Var]} -> + Anno = case Anno0 of + #{arg_types := ArgTypes0} -> + case ArgTypes0 of + #{1 := Type} -> + Anno0#{arg_types => #{0 => Type}}; + #{} -> + Anno0 + end; + #{} -> + Anno0 + end, + Set#b_set{anno=Anno,args=[Var,Lit]}; + {_, _} -> Set end; normalize(#b_set{}=Set) -> |