WebAssembly / WebAssembly/binaryen

Optimize comparisons of adjusted values

Open
#5,008 4 comments 0 reactions 1 assignee View on GitHub

@kripken is already working on this.

Since Sep 9, 2022.

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

Description

E.g.

  (i32.gt_u
   (i32.shr_u
    (local.get $0)
    (i32.const 1)
   )
   (i32.const 100)
  )
 =->
  (i32.gt_u
   (local.get $0)
   (i32.const 201)
  )

Instead of dividing by 2 and then comparing, we can compare the original value.

More variations: add a constant, or both add and multiply/divide.

Found by the superoptimizer https://github.com/WebAssembly/binaryen/pull/4994 (for comparison to other findings: rule #8, benefit 30492).

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.