WebAssembly / WebAssembly/binaryen

[Idea] Compress f64.const in integer domain for optimization for size

Open
#5,020 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
8.6k
Forks
885
Avg merge
1d 19h
Merged PRs (30d)
69

Description

Since f64 operations do not use LEB128 encoding, such constants always takes 8 bytes. Although some constants like 2.0, 3.25, 16.0, etc. have an empty or partially filled mantissa, which can be utilized for compression in integer domain. Here are some examples:

f64.const 4.0

is equivalent to set:

i64.const 1025
i64.const 52
i64.shl
f64.reinterpret_i64

Which is on 2 bytes less than floating point constant.

Another example which is more impressive:

f64.const 0.0

is simply equivalent to:

i64.const 0
f64.reinterpret_i64

which is on 6 bytes less.

Constants with floating arithmetic are much rarer than those with integer arithmetic, which leads to that they do not get into the gzip / brotli dictionaries. Although one must of course prove this thesis in practice.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. First locate Binaryen's handling of f64.const and integer-domain optimizations, then measure whether the proposed encoding reduces output size in practice, including gzip and Brotli results; done means a defined approach with supporting size evidence.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
compilers, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.