From 06534b47e9aef5e11e2e8d343a50c52fb6bcaf7b Mon Sep 17 00:00:00 2001 From: aizu-m Date: Sat, 20 Jun 2026 15:14:45 +0530 Subject: [PATCH 1/2] fix operand arity of v128 store_lane in GetExprArity --- src/ir-util.cc | 5 +++-- test/decompile/simd-store-lane.txt | 32 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 test/decompile/simd-store-lane.txt diff --git a/src/ir-util.cc b/src/ir-util.cc index f7ce0c2bb..74fe45e87 100644 --- a/src/ir-util.cc +++ b/src/ir-util.cc @@ -285,9 +285,10 @@ ModuleContext::Arities ModuleContext::GetExprArity(const Expr& expr) const { } case ExprType::SimdLoadLane: - case ExprType::SimdStoreLane: { return {2, 1}; - } + + case ExprType::SimdStoreLane: + return {2, 0}; case ExprType::SimdShuffleOp: return {2, 1}; diff --git a/test/decompile/simd-store-lane.txt b/test/decompile/simd-store-lane.txt new file mode 100644 index 000000000..781a262b9 --- /dev/null +++ b/test/decompile/simd-store-lane.txt @@ -0,0 +1,32 @@ +;;; TOOL: run-wasm-decompile +(module + (memory 1) + + ;; store_lane consumes the address and the vector and returns nothing, so the + ;; first local.get must survive as a separate return value rather than being + ;; folded into the store. + (func (param i32 v128) (result i32 i32) + local.get 0 + local.get 0 + local.get 1 + v128.store8_lane 0 + local.get 0) + + (func (param i32 v128) + local.get 0 + local.get 1 + v128.store16_lane offset=4 1) +) +(;; STDOUT ;;; +memory M_a(initial: 1, max: 0); + +function f_a(a:int, b:simd):(int, int) { // func0 + let t0 = a; + SimdStoreLane(a, b); + return t0, a; +} + +function f_b(a:int, b:simd) { // func1 + SimdStoreLane(a, b) +} +;;; STDOUT ;;) From ad5d8b29217bb06b5a87b312970db3d6c3ed6338 Mon Sep 17 00:00:00 2001 From: aizu-m Date: Mon, 22 Jun 2026 19:20:08 +0530 Subject: [PATCH 2/2] Use an f32 stack value in the store_lane decompile test --- test/decompile/simd-store-lane.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/decompile/simd-store-lane.txt b/test/decompile/simd-store-lane.txt index 781a262b9..28b5c33d4 100644 --- a/test/decompile/simd-store-lane.txt +++ b/test/decompile/simd-store-lane.txt @@ -3,10 +3,10 @@ (memory 1) ;; store_lane consumes the address and the vector and returns nothing, so the - ;; first local.get must survive as a separate return value rather than being + ;; leading f32 must survive as a separate return value rather than being ;; folded into the store. - (func (param i32 v128) (result i32 i32) - local.get 0 + (func (param i32 v128 f32) (result f32 i32) + local.get 2 local.get 0 local.get 1 v128.store8_lane 0 @@ -20,8 +20,8 @@ (;; STDOUT ;;; memory M_a(initial: 1, max: 0); -function f_a(a:int, b:simd):(int, int) { // func0 - let t0 = a; +function f_a(a:int, b:simd, c:float):(float, int) { // func0 + let t0 = c; SimdStoreLane(a, b); return t0, a; }