diff --git a/src/coreclr/jit/codegenarm64.cpp b/src/coreclr/jit/codegenarm64.cpp index 505a2cc2409199..63a5f3a452d049 100644 --- a/src/coreclr/jit/codegenarm64.cpp +++ b/src/coreclr/jit/codegenarm64.cpp @@ -4536,7 +4536,8 @@ void CodeGen::genCodeForCompare(GenTreeOp* tree) regNumber op1Reg = op1->GetRegNum(); if (compiler->opts.OptimizationEnabled() && (ins == INS_cmp) && (targetReg != REG_NA) && - tree->OperIs(GT_LT) && intConst->IsIntegralConst(0) && ((cmpSize == EA_4BYTE) || (cmpSize == EA_8BYTE))) + tree->OperIs(GT_LT) && !tree->IsUnsigned() && intConst->IsIntegralConst(0) && + ((cmpSize == EA_4BYTE) || (cmpSize == EA_8BYTE))) { emit->emitIns_R_R_I(INS_lsr, cmpSize, targetReg, op1Reg, (int)cmpSize * 8 - 1); genProduceReg(tree); diff --git a/src/tests/JIT/opt/Regressions/Regression7.cs b/src/tests/JIT/opt/Regressions/Regression7.cs new file mode 100644 index 00000000000000..da4ba23bebe323 --- /dev/null +++ b/src/tests/JIT/opt/Regressions/Regression7.cs @@ -0,0 +1,28 @@ +// 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 v1.5 on 2023-03-19 17:44:38 +// Run on Arm64 Linux +// Seed: 516098027771570682 +public class C0 +{ + public uint F1; + public C0(uint f1) + { + F1 = f1; + } +} + +public class Program +{ + // This test was testing an ARM64 regression when optimizing 'x < 0' when it didn't take into account an unsigned operation. + public static int Main() + { + var vr1 = new C0(4294967295U); + bool vr3 = !(vr1.F1 > -1); + if (!vr3) + return 100; + else + return 0; + } +} \ No newline at end of file diff --git a/src/tests/JIT/opt/Regressions/Regression7.csproj b/src/tests/JIT/opt/Regressions/Regression7.csproj new file mode 100644 index 00000000000000..f3e1cbd44b4041 --- /dev/null +++ b/src/tests/JIT/opt/Regressions/Regression7.csproj @@ -0,0 +1,12 @@ + + + Exe + + + None + True + + + + +