From f1d3554a8605dabd7d0bd03df000202bb56fe5ad Mon Sep 17 00:00:00 2001 From: Adam Perlin Date: Fri, 2 Oct 2026 17:42:25 -0700 Subject: [PATCH] Fold Wasm array data offsets into memory instructions Group managed array bases with scaled indices so existing Wasm address containment can fold the constant data offset. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3b811db0-9eed-49dc-b08d-e23832b0da50 --- src/coreclr/jit/morph.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index ca67928fd3e9b1..492de0bafcbdb0 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -3118,6 +3118,9 @@ GenTree* Compiler::fgMorphIndexAddr(GenTreeIndexAddr* indexAddr) { groupArrayRefWithIndex = false; } +#elif defined(TARGET_WASM) + // Keep the constant offset outermost so it can fold into the memory instruction's memarg. + groupArrayRefWithIndex = varTypeIsGC(arrRef) && !varTypeIsStruct(elemTyp); #endif // Note the array reference may now be TYP_I_IMPL, TYP_BYREF, or TYP_REF