Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Also handle embedded broadcasts for mismatched memory sizes
  • Loading branch information
tannergooding authored and github-actions committed Sep 22, 2023
commit 9b54bfda37ca3e4c8756e75da496a77dbb0135e9
5 changes: 2 additions & 3 deletions src/coreclr/jit/lowerxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8205,7 +8205,7 @@ bool Lowering::IsContainableHWIntrinsicOp(GenTreeHWIntrinsic* parentNode, GenTre
var_types parentBaseType = parentNode->GetSimdBaseType();
var_types childBaseType = hwintrinsic->GetSimdBaseType();

if (varTypeIsSmall(parentBaseType) || varTypeIsSmall(childBaseType))
if (varTypeIsSmall(parentBaseType) || (genTypeSize(parentBaseType) != genTypeSize(childBaseType)))
{
// early return if either base type is not embedded broadcast compatible.
return false;
Expand Down Expand Up @@ -8251,12 +8251,11 @@ bool Lowering::IsContainableHWIntrinsicOp(GenTreeHWIntrinsic* parentNode, GenTre
var_types parentBaseType = parentNode->GetSimdBaseType();
var_types childBaseType = hwintrinsic->GetSimdBaseType();

if (varTypeIsSmall(parentBaseType))
if (varTypeIsSmall(parentBaseType) || (genTypeSize(parentBaseType) != genTypeSize(childBaseType)))
{
// early return if either base type is not embedded broadcast compatible.
return false;
}
assert(!varTypeIsSmall(childBaseType));

return parentNode->OperIsEmbBroadcastCompatible();
}
Expand Down
23 changes: 18 additions & 5 deletions src/tests/JIT/Regression/JitBlue/Runtime_92357/Runtime_92357.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,30 @@ public static void Problem()
return;
}

int y = 5;
int y1 = 5;

Vector256<short> actual = Test(Vector256.Create((short)1), ref y);
Vector256<short> expected = Vector256.Create(10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0);
Vector256<short> actual1 = Test1(Vector256.Create((short)1), ref y1);
Vector256<short> expected1 = Vector256.Create(10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0);

Assert.Equal(expected, actual);
Assert.Equal(expected1, actual1);

long y2 = 5;

Vector256<int> actual2 = Test2(Vector256.Create((int)1), ref y2);
Vector256<int> expected2 = Vector256.Create(10, 0, 10, 0, 10, 0, 10, 0);

Assert.Equal(expected2, actual2);
}

[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
public static Vector256<short> Test(Vector256<short> x, ref int y)
public static Vector256<short> Test1(Vector256<short> x, ref int y)
{
return Avx2.MultiplyLow(x + x, Vector256.Create(y).AsInt16());
}

[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
public static Vector256<int> Test2(Vector256<int> x, ref long y)
{
return Avx2.MultiplyLow(x + x, Vector256.Create(y).AsInt32());
}
}