diff options
| author | Guillaume Melquiond | 2020-12-27 11:24:07 +0100 |
|---|---|---|
| committer | Guillaume Melquiond | 2021-01-10 10:24:10 +0100 |
| commit | ee5fa81585a67cc556b19e145f518b641c40ffb7 (patch) | |
| tree | 39878a20f2aa80ea5626a7fcd63de97b0929e57f /kernel/declarations.ml | |
| parent | 944757e10651fda0d63d9291a6bcb1b6fdbaa256 (diff) | |
Add a peephole optimization for PUSHFIELDS(1).
The PUSHFIELDS opcode is a costly one, yet lots of constructors have at
most one usable argument (e.g., option, nat, positive, Z, Acc). For those
constructors, PUSHFIELDS(1) is replaced by GETFIELD(0);PUSH, assuming
the accu register is no longer used afterwards.
Replacing one single opcode by two opcodes might seem like a
pessimization, but it is not. Indeed, pattern-matching branches usually
start by filling the accu register with a constructor argument or the
value of a free variable or a constant. All of those offer peephole
optimizations for PUSH, which means that the number of opcodes actually
stay constant.
Note that, for the same reason, the assumption above holds in practice:
the accu register is no longer used after PUSHFIELDS.
Diffstat (limited to 'kernel/declarations.ml')
0 files changed, 0 insertions, 0 deletions
