Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: Fix ShiftRightLogical constant folding #105571

Merged
merged 7 commits into from
Jul 29, 2024
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
4 changes: 2 additions & 2 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30912,9 +30912,9 @@ GenTree* Compiler::gtFoldExprHWIntrinsic(GenTreeHWIntrinsic* tree)

int64_t shiftAmount = otherNode->AsVecCon()->GetElementIntegral(TYP_LONG, 0);

if ((genTypeSize(simdBaseType) != 8) && (shiftAmount > INT_MAX))
if ((uint64_t)shiftAmount >= ((uint64_t)genTypeSize(simdBaseType) * BITS_PER_BYTE))
EgorBo marked this conversation as resolved.
Show resolved Hide resolved
{
// Ensure we don't lose track the the amount is an overshift
// Set to -1 to indicate an explicit overshift
shiftAmount = -1;
}

Expand Down
40 changes: 40 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_105558/Runtime_105558.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// Generated by Fuzzlyn v2.1 on 2024-07-26 12:56:41
// Run on X64 Windows
// Seed: 13544108888657591911-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
// Reduced from 290.9 KiB to 0.6 KiB in 00:02:37
// Debug: Prints 1 line(s)
// Release: Prints 0 line(s)
using System;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;

public struct S0
{
public int F0;
}

public struct S1
{
public S0 F5;
}

public class Runtime_105558
{
public static S1 s_3;

[Fact]

Check failure on line 28 in src/tests/JIT/Regression/JitBlue/Runtime_105558/Runtime_105558.cs

View check run for this annotation

Azure Pipelines / runtime (Build coreclr Common Pri0 Test Build AnyOS AnyCPU checked)

src/tests/JIT/Regression/JitBlue/Runtime_105558/Runtime_105558.cs#L28

src/tests/JIT/Regression/JitBlue/Runtime_105558/Runtime_105558.cs(28,6): error CS0246: The type or namespace name 'FactAttribute' could not be found (are you missing a using directive or an assembly reference?) [/__w/1/s/src/tests/JIT/Regression/JitBlue/Runtime_105558/Runtime_105558.csproj]

Check failure on line 28 in src/tests/JIT/Regression/JitBlue/Runtime_105558/Runtime_105558.cs

View check run for this annotation

Azure Pipelines / runtime (Build coreclr Common Pri0 Test Build AnyOS AnyCPU checked)

src/tests/JIT/Regression/JitBlue/Runtime_105558/Runtime_105558.cs#L28

src/tests/JIT/Regression/JitBlue/Runtime_105558/Runtime_105558.cs(28,6): error CS0246: The type or namespace name 'Fact' could not be found (are you missing a using directive or an assembly reference?) [/__w/1/s/src/tests/JIT/Regression/JitBlue/Runtime_105558/Runtime_105558.csproj]
public static void TestEntryPoint()
{
var vr17 = Vector128.CreateScalar(2558356441U);
var vr18 = Vector128.Create(0, 3113514718U, 0, 0);
var vr19 = Sse2.ShiftRightLogical(vr17, vr18);
if (0 >= Sse2.ConvertToUInt32(vr19))
{
return;
}
throw new InvalidOperationException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>
Loading