Skip to content

Commit b652b39

Browse files
Ensure mini-amd64 correctly handles CMP_GT and CMP_GE for OP_XCOMPARE_FP (#104206)
* Ensure mini-amd64 correctly handles CMP_GT and CMP_GE for OP_XCOMPARE_FP * Re-enable the tests disabled due to #97176
1 parent 25b9210 commit b652b39

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

src/libraries/System.Runtime.Intrinsics/tests/Vectors/Vector128Tests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4826,7 +4826,6 @@ private static void TestCreateSequence<T>(T start, T step)
48264826

48274827
[Theory]
48284828
[MemberData(nameof(VectorTestMemberData.ExpDouble), MemberType = typeof(VectorTestMemberData))]
4829-
[SkipOnMono("https://github.com/dotnet/runtime/issues/97176")]
48304829
public void ExpDoubleTest(double value, double expectedResult, double variance)
48314830
{
48324831
Vector128<double> actualResult = Vector128.Exp(Vector128.Create(value));
@@ -4835,7 +4834,6 @@ public void ExpDoubleTest(double value, double expectedResult, double variance)
48354834

48364835
[Theory]
48374836
[MemberData(nameof(VectorTestMemberData.ExpSingle), MemberType = typeof(VectorTestMemberData))]
4838-
[SkipOnMono("https://github.com/dotnet/runtime/issues/97176")]
48394837
public void ExpSingleTest(float value, float expectedResult, float variance)
48404838
{
48414839
Vector128<float> actualResult = Vector128.Exp(Vector128.Create(value));

src/libraries/System.Runtime.Intrinsics/tests/Vectors/Vector256Tests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5841,7 +5841,6 @@ private static void TestCreateSequence<T>(T start, T step)
58415841

58425842
[Theory]
58435843
[MemberData(nameof(VectorTestMemberData.ExpDouble), MemberType = typeof(VectorTestMemberData))]
5844-
[SkipOnMono("https://github.com/dotnet/runtime/issues/97176")]
58455844
public void ExpDoubleTest(double value, double expectedResult, double variance)
58465845
{
58475846
Vector256<double> actualResult = Vector256.Exp(Vector256.Create(value));
@@ -5850,7 +5849,6 @@ public void ExpDoubleTest(double value, double expectedResult, double variance)
58505849

58515850
[Theory]
58525851
[MemberData(nameof(VectorTestMemberData.ExpSingle), MemberType = typeof(VectorTestMemberData))]
5853-
[SkipOnMono("https://github.com/dotnet/runtime/issues/97176")]
58545852
public void ExpSingleTest(float value, float expectedResult, float variance)
58555853
{
58565854
Vector256<float> actualResult = Vector256.Exp(Vector256.Create(value));

src/libraries/System.Runtime.Intrinsics/tests/Vectors/Vector512Tests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5274,7 +5274,6 @@ private static void TestCreateSequence<T>(T start, T step)
52745274

52755275
[Theory]
52765276
[MemberData(nameof(VectorTestMemberData.ExpDouble), MemberType = typeof(VectorTestMemberData))]
5277-
[SkipOnMono("https://github.com/dotnet/runtime/issues/97176")]
52785277
public void ExpDoubleTest(double value, double expectedResult, double variance)
52795278
{
52805279
Vector512<double> actualResult = Vector512.Exp(Vector512.Create(value));
@@ -5283,7 +5282,6 @@ public void ExpDoubleTest(double value, double expectedResult, double variance)
52835282

52845283
[Theory]
52855284
[MemberData(nameof(VectorTestMemberData.ExpSingle), MemberType = typeof(VectorTestMemberData))]
5286-
[SkipOnMono("https://github.com/dotnet/runtime/issues/97176")]
52875285
public void ExpSingleTest(float value, float expectedResult, float variance)
52885286
{
52895287
Vector512<float> actualResult = Vector512.Exp(Vector512.Create(value));

src/mono/mono/mini/mini-amd64.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4072,8 +4072,26 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
40724072
case CMP_NE: ins->inst_c0 = 4; break;
40734073
case CMP_LT: ins->inst_c0 = 1; break;
40744074
case CMP_LE: ins->inst_c0 = 2; break;
4075-
case CMP_GT: ins->inst_c0 = 6; break;
4076-
case CMP_GE: ins->inst_c0 = 5; break;
4075+
case CMP_GT: {
4076+
// CMPNLT (5) is not the same as CMPGT due to NaN
4077+
// as such, we want to emit CMPLT (1) with swapped
4078+
// operands instead, ensuring we get correct handling
4079+
int tmp = ins->sreg1;
4080+
ins->sreg1 = ins->sreg2;
4081+
ins->sreg2 = tmp;
4082+
ins->inst_c0 = 1;
4083+
break;
4084+
}
4085+
case CMP_GE: {
4086+
// CMPNLE (6) is not the same as CMPGE due to NaN
4087+
// as such, we want to emit CMPLE (2) with swapped
4088+
// operands instead, ensuring we get correct handling
4089+
int tmp = ins->sreg1;
4090+
ins->sreg1 = ins->sreg2;
4091+
ins->sreg2 = tmp;
4092+
ins->inst_c0 = 2;
4093+
break;
4094+
}
40774095
default:
40784096
g_assert_not_reached();
40794097
break;

0 commit comments

Comments
 (0)