[Emitting Zero] [Local Tracking] General rule might not handle unary ne emitting zero bits well
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- wasm
- 領域
- compilers
調査の方向性
まず、提供された WebAssembly モジュールを、コミット 755a8d0e の wasm-opt で -O2 および -all -O3 を指定して実行し、その後、最適化結果を比較します。関連するコンテキストとして issue #7492 を参照しながら、ローカルトラッキングと単項比較の処理を追跡します。完了条件は、-O3 でも条件が true であると推論され、分岐が到達不能になることです。
索引モデルが issue の本文から書いたものです。
説明
Given the following code:
(module
(import "External" "external_function" (func $external_function))
(func $foo (result i32)
i32.const 0
i32.load)
(func $_start (param $0 i32) (param $1 i64) (param $2 i32)
(local $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) (local $7 i32) (local $9 i32)
call $foo
local.set $4
i32.const 1
local.set $3
local.get $4
local.get $3
i32.shl
i32.const 1
i32.shr_s
local.set $6
i32.const 0
i32.const 0
i32.store
i32.const -259031342
local.set $7
local.get $6
local.get $7
i32.ne
local.set $9
block ;; label = @1
local.get $9
i32.eqz
br_if 0 (;@1;)
unreachable
end
call $bar)
(func $bar call $external_function)
(memory $0 258 258)
(export "_start" (func $_start)))
wasm-opt (755a8d0e) should deduce the condition to false, thus fold the branch to unreachable (further deleting call $bar), which works under -O2 but fails under -O3.
Below is optimized by -all -O3:
(func $_start (type $1) (param $0 i32) (param $1 i64) (param $2 i32)
(local.set $0
(i32.shr_s
(i32.shl
(i32.load
(i32.const 0)
)
(i32.const 1)
)
(i32.const 1)
)
)
(i32.store
(i32.const 0)
(i32.const 0)
)
(if
(i32.ne
(local.get $0)
(i32.const -259031342)
)
(then
(unreachable)
)
)
(call $external_function)
)
As you can see, the condition here
(i32.ne
(local.get $0)
(i32.const -259031342)
)
is not deduced to true.
Similar to #7492, Maybe there a missing rule for it to emit zero bits, or is the local tracking insufficient?
- 主要言語
- 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
-
flang:fir-hlfir
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
llvm/llvm-project#225935 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
objectionary/eo#8923 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
Coarray integration tests carry no LABELS, so run_tests.py silently skips them under every backend オープンcoarray
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100