From 79bc057a7d238f31c597fda2f8fa41918e0fd37a Mon Sep 17 00:00:00 2001 From: SingleAccretion Date: Thu, 16 Jun 2022 18:00:18 +0300 Subject: [PATCH 1/2] Tighten checks in "areArgumentsContiguous" --- src/coreclr/jit/simd.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/coreclr/jit/simd.cpp b/src/coreclr/jit/simd.cpp index 92706856a0dce8..f55e8911e10408 100644 --- a/src/coreclr/jit/simd.cpp +++ b/src/coreclr/jit/simd.cpp @@ -1685,7 +1685,15 @@ bool Compiler::areArrayElementsContiguous(GenTree* op1, GenTree* op2) // bool Compiler::areArgumentsContiguous(GenTree* op1, GenTree* op2) { - if (op1->OperIs(GT_IND) && op2->OperIs(GT_IND)) + if (op1->TypeGet() != op2->TypeGet()) + { + return false; + } + + assert(!op1->TypeIs(TYP_STRUCT)); + + if (op1->OperIs(GT_IND) && op1->AsIndir()->Addr()->OperIs(GT_INDEX_ADDR) && op2->OperIs(GT_IND) && + op2->AsIndir()->Addr()->OperIs(GT_INDEX_ADDR)) { return areArrayElementsContiguous(op1, op2); } From 0ed26279f512f6543cfcf0dd006566cddfa0d885 Mon Sep 17 00:00:00 2001 From: SingleAccretion Date: Thu, 16 Jun 2022 18:01:02 +0300 Subject: [PATCH 2/2] Add a test --- .../JitBlue/Runtime_70824/Runtime_70824.cs | 48 +++++++++++++++++++ .../Runtime_70824/Runtime_70824.csproj | 10 ++++ 2 files changed, 58 insertions(+) create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_70824/Runtime_70824.cs create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_70824/Runtime_70824.csproj diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_70824/Runtime_70824.cs b/src/tests/JIT/Regression/JitBlue/Runtime_70824/Runtime_70824.cs new file mode 100644 index 00000000000000..e312cf524a8ed1 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_70824/Runtime_70824.cs @@ -0,0 +1,48 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Numerics; +using System.Runtime.CompilerServices; + +public unsafe class Runtime_70824 +{ + public static int Main() + { + long lng = 2; + float flt = 3; + Vector2 vtor = new Vector2(4, 5); + float[] arr = new float[] { 6, 7 }; + + if (ProblemWithTypes(&lng, &flt, vtor)) + { + return 101; + } + if (ProblemWithAddrs(&flt, arr, vtor)) + { + return 102; + } + + return 100; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private static bool ProblemWithTypes(long* p1, float* pF, Vector2 vtor) + { + *pF = vtor.X; + *p1 = (long)*pF; + + return *p1 != (long)*pF; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private static bool ProblemWithAddrs(float* pF, float[] arr, Vector2 vtor) + { + *pF = vtor.X; + arr[0] = vtor.Y; + + arr[1] = vtor.X; + *pF = vtor.Y; + + return arr[0] != vtor.Y || *pF != vtor.Y; + } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_70824/Runtime_70824.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_70824/Runtime_70824.csproj new file mode 100644 index 00000000000000..cf94135633b19a --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_70824/Runtime_70824.csproj @@ -0,0 +1,10 @@ + + + Exe + True + true + + + + + \ No newline at end of file