SimplifyLocals causes ineffective code
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- wasm
- 領域
- compilers
調査の方向性
-O3 および -O3 -sp=simplify-locals を使用して wasm-opt で例を再現し、その後 simplify-locals のエントリーポイントと、続いて行われる条件最適化を調査します。2 回の実行で生成された WebAssembly を比較します。この入力に対する回帰テストがあり、到達可能な動作を誤って削除することなく、見逃されていた最適化が対処されていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Given the following code:
(module
(type (;0;) (func))
(import "External" "external_function" (func $external_function (type 0)))
(func $_start (type 0)
i32.const 9576
i32.load
i32.load
i32.load
drop
i32.const 9576
i32.load
i32.load
i32.load
i32.const 9576
i32.load
i32.load
i32.load
i32.gt_s
if (result i32) ;; label = @1
call $external_function
i32.const 1
else
i32.const 0
end
drop
unreachable)
(memory $0 258 258)
(export "_start" (func $_start)))
For wasm-opt (c91c0520a61), -O3 -sp=simplify-locals can eliminate the unreachable code, while -O3 cannot:
(func $_start
(local $0 i32)
(if
(i32.gt_s
(local.tee $0
(i32.load
(i32.load
(i32.load
(i32.const 9576)
)
)
)
)
(local.get $0)
)
(then
(call $external_function)
)
)
(unreachable)
)
After investigating, it is the Wasm-specific optimization simplify-locals causes the counter-intuitive code. Below is the change made by simplify-locals:
As you can see, the currently wasm-opt cannot optimize the if condition on the right---it can only do that on the left, which I think it is missed optimization (It is not the simplify-locals fault...).
- 主要言語
- WebAssembly
- スター
- 8.6k
- フォーク
- 885
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 77
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
WebAssembly/binaryen のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
WebAssembly/binaryen#9135 · コメント 1 件 ·
-
難易度 2/5 半日 初心者へのやさしさ 76/100
WebAssembly/binaryen#9018 · コメント 3 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
WebAssembly/binaryen#9133 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
WebAssembly/binaryen#9123 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
WebAssembly/binaryen#9122 ·
WebAssembly/binaryen の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
internal.h中,漏掉了1个定义。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
oxc-project/oxc#26944 ·