Fix missing offset in contained BITCAST for STORE_LCL_FLD (#57059)
authorJakob Botsch Nielsen <Jakob.botsch.nielsen@gmail.com>
Mon, 9 Aug 2021 17:20:39 +0000 (19:20 +0200)
committerGitHub <noreply@github.com>
Mon, 9 Aug 2021 17:20:39 +0000 (19:20 +0200)
src/coreclr/jit/codegenxarch.cpp
src/tests/JIT/Regression/JitBlue/Runtime_55141/Runtime_55141_2.cs [new file with mode: 0644]
src/tests/JIT/Regression/JitBlue/Runtime_55141/Runtime_55141_2.csproj [new file with mode: 0644]

index 529d1fe..f268c6a 100644 (file)
@@ -4450,7 +4450,7 @@ void CodeGen::genCodeForStoreLclFld(GenTreeLclFld* tree)
             LclVarDsc* varDsc = compiler->lvaGetDesc(lclNum);
 
             GetEmitter()->emitIns_S_R(ins_Store(srcType, compiler->isSIMDTypeLocalAligned(lclNum)),
-                                      emitTypeSize(targetType), bitCastSrc->GetRegNum(), lclNum, 0);
+                                      emitTypeSize(targetType), bitCastSrc->GetRegNum(), lclNum, tree->GetLclOffs());
             varDsc->SetRegNum(REG_STK);
         }
         else
diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_55141/Runtime_55141_2.cs b/src/tests/JIT/Regression/JitBlue/Runtime_55141/Runtime_55141_2.cs
new file mode 100644 (file)
index 0000000..2d70237
--- /dev/null
@@ -0,0 +1,38 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+// Generated by Fuzzlyn v1.2 on 2021-07-22 13:45:33
+// Seed: 7718323254176193466
+// Reduced from 89.3 KiB to 0.4 KiB in 00:00:46
+// Debug: Outputs 1
+// Release: Outputs 0
+
+using System.Runtime.CompilerServices;
+
+struct S2
+{
+    public uint F0;
+    public long F1;
+    public uint F2;
+    public short F3;
+    public bool F4;
+    public S2(uint f0, uint f2): this()
+    {
+        F0 = f0;
+        F2 = f2;
+    }
+}
+
+public class Runtime_55141_2
+{
+    static int s_1;
+    public static int Main()
+    {
+        int vr23 = s_1;
+        S2 vr29 = new S2(1, (uint)vr23 / 40319);
+        return M(vr29.F0) == 1 ? 100 : -1;
+    }
+    
+    [MethodImpl(MethodImplOptions.NoInlining)]
+    private static uint M(uint val) => val;
+}
\ No newline at end of file
diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_55141/Runtime_55141_2.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_55141/Runtime_55141_2.csproj
new file mode 100644 (file)
index 0000000..e8e73ed
--- /dev/null
@@ -0,0 +1,10 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <Optimize>True</Optimize>
+    <DebugType>None</DebugType>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="$(MSBuildProjectName).cs" />
+  </ItemGroup>
+</Project>
\ No newline at end of file