diff options
author | John Högberg <[email protected]> | 2019-01-21 07:25:47 +0100 |
---|---|---|
committer | John Högberg <[email protected]> | 2019-01-24 08:37:37 +0100 |
commit | 294d66a295f6c2101fe3c2da630979ad4e736c08 (patch) | |
tree | 7a74227c185c69a976bd90b521eddd47d01db5d3 /lib/compiler/src/beam_ssa_pre_codegen.erl | |
parent | 1c73a313e72909d054f55e321c1929d2be55ff11 (diff) | |
download | otp-294d66a295f6c2101fe3c2da630979ad4e736c08.tar.gz otp-294d66a295f6c2101fe3c2da630979ad4e736c08.tar.bz2 otp-294d66a295f6c2101fe3c2da630979ad4e736c08.zip |
compiler: Introduce module-level type optimization
This commit lets the type optimization pass work across functions,
tracking return and argument types to eliminate redundant tests.
Diffstat (limited to 'lib/compiler/src/beam_ssa_pre_codegen.erl')
-rw-r--r-- | lib/compiler/src/beam_ssa_pre_codegen.erl | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/compiler/src/beam_ssa_pre_codegen.erl b/lib/compiler/src/beam_ssa_pre_codegen.erl index fa1b7bb71e..03d193db4d 100644 --- a/lib/compiler/src/beam_ssa_pre_codegen.erl +++ b/lib/compiler/src/beam_ssa_pre_codegen.erl @@ -1031,7 +1031,7 @@ need_frame_1([#b_set{op=call,args=[Func|_]}|Is], Context) -> case Func of #b_remote{mod=#b_literal{val=Mod}, name=#b_literal{val=Name}, - arity=Arity} -> + arity=Arity} when is_atom(Mod), is_atom(Name) -> case erl_bifs:is_exit_bif(Mod, Name, Arity) of true -> false; @@ -1993,6 +1993,12 @@ reserve_zregs(Blocks, Intervals, Res) -> end, beam_ssa:fold_rpo(F, [0], Res, Blocks). +reserve_zreg([#b_set{op=call,dst=Dst}], + #b_br{bool=Dst}, _ShortLived, A) -> + %% If type optimization has determined that the result of a call can be + %% used directly in a branch, we must avoid reserving a z register or code + %% generation will fail. + A; reserve_zreg([#b_set{op={bif,tuple_size},dst=Dst}, #b_set{op={bif,'=:='},args=[Dst,Val]}], Last, ShortLived, A0) -> case {Val,Last} of |