Skip to content

Commit cd87c0b

Browse files
Ensure that embedded broadcast is correctly checking for EVEX support before use (#105659)
* Ensure that embedded broadcast is correctly checking for EVEX support before use * Only run the test if Avx is supported
1 parent 2485745 commit cd87c0b

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

src/coreclr/jit/lowerxarch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8292,7 +8292,7 @@ bool Lowering::IsContainableHWIntrinsicOp(GenTreeHWIntrinsic* parentNode, GenTre
82928292
return false;
82938293
}
82948294

8295-
return parentNode->OperIsEmbBroadcastCompatible();
8295+
return parentNode->OperIsEmbBroadcastCompatible() && comp->canUseEvexEncoding();
82968296
}
82978297

82988298
default:
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 System;
5+
using System.Runtime.Intrinsics;
6+
using System.Runtime.Intrinsics.X86;
7+
using System.Runtime.CompilerServices;
8+
using Xunit;
9+
10+
public class Runtime_96156
11+
{
12+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
13+
private unsafe static Vector128<float> BroadcastScalarToVector128(float value)
14+
{
15+
return Avx.BroadcastScalarToVector128(&value);
16+
}
17+
18+
[Fact]
19+
public static void TestEntryPoint()
20+
{
21+
if (Avx.IsSupported)
22+
{
23+
Vector128<float> c = Vector128.Create(1.0f);
24+
Vector128<float> r = Problem(2.0f, 0.5f, c);
25+
Assert.Equal(Vector128.Create(4.0f), r);
26+
}
27+
}
28+
29+
[MethodImpl(MethodImplOptions.NoInlining)]
30+
private static Vector128<float> Problem(float a, float b, Vector128<float> c)
31+
{
32+
return Avx.Multiply(c, BroadcastScalarToVector128(a / b));
33+
}
34+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
4+
<Optimize>True</Optimize>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<Compile Include="$(MSBuildProjectName).cs" />
8+
</ItemGroup>
9+
<ItemGroup>
10+
<CLRTestEnvironmentVariable Include="DOTNET_EnableAVX512F" Value="0" />
11+
<CLRTestEnvironmentVariable Include="DOTNET_TieredCompilation" Value="0" />
12+
</ItemGroup>
13+
</Project>

0 commit comments

Comments
 (0)