This is similar to #8016 & #8002
See this repro.tar.gz. The optimized version was obtained via open world compilation
% wasm-opt \
--enable-gc --enable-reference-types --enable-multivalue --enable-exception-handling --enable-nontrapping-float-to-int \
--enable-sign-ext --enable-bulk-memory --enable-threads \
--enable-simd '--no-inline=*<noInline>*' --traps-never-happen \
-g -Os -Os -Os \
repro.wasm -o repro.opt.wasm
It leaves the following behind
(type $JSExternWrapper (sub $Object (struct
(field $field0 i32)
(field $field1 (mut i32))
(field $_externRef externref))))
(global $.a (import "" "a") (ref extern))
(global $"C284 \"a\"" (ref $JSExternWrapper) (i32.const 97) (i32.const 0) (global.get $.a) (struct.new $JSExternWrapper))
(func $"findExact <noInline>" (param $var0 (ref $JSExternWrapper)) (result i64)
(local $var1 (ref $JSExternWrapper))
block $label0
block $label1
block $label2
block $label3 (result i32)
block $label4
global.get $"C284 \"a\""
local.tee $var1
struct.get $JSExternWrapper $field0
i32.const 97
i32.ne
br_if $label4
local.get $var0
struct.get $JSExternWrapper $_externRef
local.get $var1
struct.get $JSExternWrapper $_externRef
call $"wasm:js-string.equals (import)"
i32.eqz
br_if $label4
i32.const 1
br $label3
end $label4
i32.const 0
end $label3
i32.eqz
Notice that the
$C284 global is a non mutable global with known values being initialized
$JSExternWrapper.$field0 is a non mutable i32 field
Therefore the
global.get $"C284 \"a\""
local.tee $var1
struct.get $JSExternWrapper $field0
should be turned into
and the
local.get $var1
struct.get $JSExternWrapper $_externRef
should be turned into
This is similar to #8016 & #8002
See this repro.tar.gz. The optimized version was obtained via open world compilation
It leaves the following behind
Notice that the
$C284global is a non mutable global with known values being initialized$JSExternWrapper.$field0is a non mutablei32fieldTherefore the
should be turned into
and the
should be turned into