Closed
Description
Found with LLM-Fuzz
Assert failure(PID 64060 [0x0000fa3c], Thread: 75004 [0x124fc]): Assertion failed 'op1ArrayRef->TypeGet() == TYP_REF' in 'VectorTest+SimpleVector3:Vector3GetHashCodeTest(byref)' during 'Morph - Structs/AddrExp' (IL size 378; hash 0xb5244881; FullOpts)
File: C:\repos\runtime1\src\coreclr\jit\simd.cpp:633
Compile and run with DOTNET_TieredCompilation=0
. May require AVX-512.
// Mutation 5
using System;
using System.Numerics;
using System.Collections.Generic;
// using Xunit;
public partial class VectorTest
{
private const int Pass = 100;
private const int Fail = -1;
public class Assert
{
public static void Equal(float a, float b)
{
if (a != b)
throw new Exception("Assert.Equal failed");
}
public static void NotEqual(float a, float b)
{
if (a == b)
throw new Exception("Assert.NotEqual failed");
}
}
public struct SimpleVector3
{
// Introduce lambda expressions to process array values.
static Func<int, int> multiply = x => x * 2;
public static void Vector3GetHashCodeTest(ref int checksum)
{
Vector3 one = new Vector3(2.0f, 3.0f, 3.3f);
Vector3 two = new Vector3(2.0f, 3.0f, 3.3f);
Vector3 three = new Vector3(3.0f, 2.0f, 3.3f);
Assert.Equal(one.GetHashCode(), two.GetHashCode());
Assert.NotEqual(one.GetHashCode(), three.GetHashCode());
Vector3 zero = new Vector3(0.0f, 0.0f, 0.0f);
Vector3 oneAxis = new Vector3(1.0f, 0.0f, 0.0f);
Assert.NotEqual(zero.GetHashCode(), oneAxis.GetHashCode());
// Create an array and then use a for-loop with invariant bounds.
float[] items = new float[] { one.X, one.Y, one.Z, three.X, three.Y };
for (int i = 0, cnt = items.Length; i < cnt; i++)
{
checksum += (int)(items[i] * 1.0f);
}
// Use a for-each loop conditionally.
if (checksum % 4 == 0)
{
foreach (float f in items)
{
checksum += multiply((int)f);
}
}
Console.WriteLine("Intermediate Checksum (Mutation 5): " + checksum);
}
// [Fact]
public static int Main()
{
int checksum = 19;
int returnVal = Pass;
try
{
Vector3GetHashCodeTest(ref checksum);
}
catch (Exception ex)
{
Console.WriteLine("FAILED: " + ex.Message);
returnVal = Fail;
}
// Additional clonable loop using same array in a different context.
int[] reusedArray = { 2, 4, 6, 8, 10 };
for (int i = 0, length = reusedArray.Length; i < length; i++)
{
checksum += (i % 2 == 0) ? reusedArray[i] : -reusedArray[i];
}
Console.WriteLine("Final Checksum (Mutation 5): " + checksum);
return returnVal;
}
}
}