Skip to content

Commit 27dd261

Browse files
tannergoodingdirecthex
authored andcommitted
Ensure constant evaluation of shifts on xarch broadcast the operand to the correct size (#105487)
* Ensure constant evaluation of shifts on xarch broadcast the operand to the correct size * Ensure we don't try to execute AVX2 code on unsupported platforms
1 parent 5ce7d3f commit 27dd261

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

src/coreclr/jit/gentree.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30917,6 +30917,10 @@ GenTree* Compiler::gtFoldExprHWIntrinsic(GenTreeHWIntrinsic* tree)
3091730917
// Ensure we don't lose track the the amount is an overshift
3091830918
shiftAmount = -1;
3091930919
}
30920+
30921+
// Ensure we broadcast to the right vector size
30922+
otherNode->gtType = retType;
30923+
3092030924
otherNode->AsVecCon()->EvaluateBroadcastInPlace(simdBaseType, shiftAmount);
3092130925
}
3092230926
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Generated by Fuzzlyn v1.7 on 2024-07-25 11:06:17
2+
// Run on X64 Windows
3+
// Seed: 1535747306914661768-vectort,vector128,vector256,x86aes,x86avx,x86avx2,x86bmi1,x86bmi1x64,x86bmi2,x86bmi2x64,x86fma,x86lzcnt,x86lzcntx64,x86pclmulqdq,x86popcnt,x86popcntx64,x86sse,x86ssex64,x86sse2,x86sse2x64,x86sse3,x86sse41,x86sse41x64,x86sse42,x86sse42x64,x86ssse3,x86x86base
4+
// Reduced from 95.3 KiB to 0.6 KiB in 00:00:29
5+
// Debug: Outputs <0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>
6+
// Release: Outputs <0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1>
7+
using System;
8+
using System.Runtime.Intrinsics;
9+
using System.Runtime.Intrinsics.X86;
10+
using Xunit;
11+
12+
public class Runtime_105465
13+
{
14+
[Fact]
15+
public static void TestEntryPoint()
16+
{
17+
if (Avx2.IsSupported)
18+
{
19+
var vr2 = Vector256.Create<ushort>(1);
20+
var vr3 = Vector128.Create<ushort>(1);
21+
Vector256<ushort> vr4 = Avx2.ShiftLeftLogical(vr2, vr3);
22+
Assert.Equal(Vector256<ushort>.Zero, vr4);
23+
}
24+
}
25+
}
26+
Lines changed: 8 additions & 0 deletions
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)