aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/compiler.app.src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2019-02-18 14:33:55 +0100
committerBjörn Gustavsson <[email protected]>2019-02-19 10:18:08 +0100
commit26c93c06ebb9b1585418d463142f63bdca071f85 (patch)
tree3dc2f224419bc854c59debac04e15b3fb7901383 /lib/compiler/src/compiler.app.src
parent6c0c1f69353b14bb9cec8d6d2ae134b54bf3b2d7 (diff)
downloadotp-26c93c06ebb9b1585418d463142f63bdca071f85.tar.gz
otp-26c93c06ebb9b1585418d463142f63bdca071f85.tar.bz2
otp-26c93c06ebb9b1585418d463142f63bdca071f85.zip
Do the destructive setelement optimization in SSA
The expansion of record field updates, when more than one field is updated, but not a majority of the fields, will create a sequence of calls to `erlang:setelement(Index, Value, Tuple)` where Tuple in the first call is the original record tuple, and in the subsequent calls Tuple is the result of the previous call. Furthermore, all Index values are constant positive integers, and the first call to `setelement` will have the greatest index. Thus all the following calls do not actually need to test at run-time whether Tuple has type tuple, nor that the index is within the tuple bounds. Since OTP R7, the `sys_core_dsetel` pass, run as the very last Core Erlang pass, has optimized this sequence of `setelement` calls to use a special destructive version of `setelement` (called `set_tuple_element`) for all but the very first `setelement` in the sequence. It turns out that the presence of the `set_tuple_element` in SSA code is awkward and can prevent or complicate type analysis and aggressive optimizations. Therefore, this commit removes the `sys_core_dsetel` pass and reimplements it for SSA code. The optimization will be done in the `beam_ssa_pre_codegen` pass (that is, just before code generation and after running all other SSA code optimization passes). In most cases, the resulting BEAM code is identical to previous code. For a few modules, the BEAM code is actually slightly better, with smaller stack frames.
Diffstat (limited to 'lib/compiler/src/compiler.app.src')
-rw-r--r--lib/compiler/src/compiler.app.src1
1 files changed, 0 insertions, 1 deletions
diff --git a/lib/compiler/src/compiler.app.src b/lib/compiler/src/compiler.app.src
index 108a0ca100..a086a3a8d3 100644
--- a/lib/compiler/src/compiler.app.src
+++ b/lib/compiler/src/compiler.app.src
@@ -65,7 +65,6 @@
rec_env,
sys_core_alias,
sys_core_bsm,
- sys_core_dsetel,
sys_core_fold,
sys_core_fold_lists,
sys_core_inline,