diff options
author | John Högberg <[email protected]> | 2019-01-18 06:23:59 +0100 |
---|---|---|
committer | John Högberg <[email protected]> | 2019-02-05 11:33:13 +0100 |
commit | 4f8026dabf5bd81f1dad085024e2b0623e5706f4 (patch) | |
tree | 8ff494cbde52f39ebcaf2ae01884c1c49512efd8 /lib/compiler/src/beam_ssa_pre_codegen.erl | |
parent | 8f4eab5dda3658850b5b123003b2786ec7e715b2 (diff) | |
download | otp-4f8026dabf5bd81f1dad085024e2b0623e5706f4.tar.gz otp-4f8026dabf5bd81f1dad085024e2b0623e5706f4.tar.bz2 otp-4f8026dabf5bd81f1dad085024e2b0623e5706f4.zip |
beam_ssa_type: Track the types of tuple elements
Prior to 294d66a295f6c2101fe3c2da630979ad4e736c08 there wasn't much
point to keeping track of tuple element types; they were only known
when we had inserted or extracted values from a tuple, and in
neither case was it likely that we'd extract the same values again.
It makes a lot more sense to do so now that type optimizations are
applied across functions; if we return a tuple it's very likely
that its elements will be extracted soon after, and knowing their
types lets us eliminate more type checks.
Co-authored-by: Björn Gustavsson <[email protected]>
Diffstat (limited to 'lib/compiler/src/beam_ssa_pre_codegen.erl')
-rw-r--r-- | lib/compiler/src/beam_ssa_pre_codegen.erl | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/compiler/src/beam_ssa_pre_codegen.erl b/lib/compiler/src/beam_ssa_pre_codegen.erl index 274f78052d..ad57a45ef2 100644 --- a/lib/compiler/src/beam_ssa_pre_codegen.erl +++ b/lib/compiler/src/beam_ssa_pre_codegen.erl @@ -1993,11 +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. +reserve_zreg([#b_set{op=Op,dst=Dst}], + #b_br{bool=Dst}, _ShortLived, A) when Op =:= call; + Op =:= get_tuple_element -> + %% If type optimization has determined that the result of these + %% instructions 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) -> |