Skip to content

Commit 2e3dd8e

Browse files
[release/9.0-staging] [mono] [llvm-aot] Fixed storing Vector3 into memory (#111069)
* [mono] [llvm-aot] Fixed storing Vector3 into memory * Removed unused variable --------- Co-authored-by: Jeremi Kurdek <[email protected]>
1 parent 6091bce commit 2e3dd8e

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

src/mono/mono/mini/mini-llvm.c

+15-1
Original file line numberDiff line numberDiff line change
@@ -8433,7 +8433,21 @@ MONO_RESTORE_WARNING
84338433
LLVMValueRef dest;
84348434

84358435
dest = convert (ctx, LLVMBuildAdd (builder, convert (ctx, values [ins->inst_destbasereg], IntPtrType ()), LLVMConstInt (IntPtrType (), ins->inst_offset, FALSE), ""), pointer_type (t));
8436-
mono_llvm_build_aligned_store (builder, lhs, dest, FALSE, 1);
8436+
if (mono_class_value_size (ins->klass, NULL) == 12) {
8437+
const int mask_values [] = { 0, 1, 2 };
8438+
8439+
LLVMValueRef truncatedVec3 = LLVMBuildShuffleVector (
8440+
builder,
8441+
lhs,
8442+
LLVMGetUndef (t),
8443+
create_const_vector_i32 (mask_values, 3),
8444+
"truncated_vec3"
8445+
);
8446+
8447+
mono_llvm_build_aligned_store (builder, truncatedVec3, dest, FALSE, 1);
8448+
} else {
8449+
mono_llvm_build_aligned_store (builder, lhs, dest, FALSE, 1);
8450+
}
84378451
break;
84388452
}
84398453
case OP_XBINOP:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using Xunit;
5+
using System.Numerics;
6+
7+
public class Foo
8+
{
9+
public Vector3 v1;
10+
public Vector3 v2;
11+
}
12+
13+
public class Runtime_110820
14+
{
15+
[Fact]
16+
public static void TestEntryPoint()
17+
{
18+
var foo = new Foo();
19+
foo.v2 = new Vector3(4, 5, 6);
20+
foo.v1 = new Vector3(1, 2, 3);
21+
Assert.Equal(new Vector3(1, 2, 3), foo.v1);
22+
Assert.Equal(new Vector3(4, 5, 6), foo.v2);
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<Optimize>True</Optimize>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<Compile Include="$(MSBuildProjectName).cs" />
7+
</ItemGroup>
8+
</Project>

0 commit comments

Comments
 (0)