@@ -8263,6 +8263,111 @@ ValueNum ValueNumStore::EvalHWIntrinsicFunBinary(GenTreeHWIntrinsic* tree,
8263
8263
break;
8264
8264
}
8265
8265
8266
+ case GT_EQ:
8267
+ {
8268
+ if (varTypeIsFloating(baseType))
8269
+ {
8270
+ // Handle `(x == NaN) == false` and `(NaN == x) == false` for floating-point types
8271
+ if (VNIsVectorNaN(type, baseType, cnsVN))
8272
+ {
8273
+ return VNZeroForType(type);
8274
+ }
8275
+ }
8276
+ break;
8277
+ }
8278
+
8279
+ case GT_GT:
8280
+ {
8281
+ ValueNum zeroVN = VNZeroForType(type);
8282
+
8283
+ if (varTypeIsUnsigned(baseType))
8284
+ {
8285
+ // Handle `(0 > x) == false` for unsigned types.
8286
+ if ((cnsVN == arg0VN) && (cnsVN == zeroVN))
8287
+ {
8288
+ return zeroVN;
8289
+ }
8290
+ }
8291
+ else if (varTypeIsFloating(baseType))
8292
+ {
8293
+ // Handle `(x > NaN) == false` and `(NaN > x) == false` for floating-point types
8294
+ if (VNIsVectorNaN(type, baseType, cnsVN))
8295
+ {
8296
+ return zeroVN;
8297
+ }
8298
+ }
8299
+ break;
8300
+ }
8301
+
8302
+ case GT_GE:
8303
+ {
8304
+ ValueNum zeroVN = VNZeroForType(type);
8305
+
8306
+ if (varTypeIsUnsigned(baseType))
8307
+ {
8308
+ // Handle `x >= 0 == true` for unsigned types.
8309
+ if ((cnsVN == arg1VN) && (cnsVN == zeroVN))
8310
+ {
8311
+ return VNAllBitsForType(type);
8312
+ }
8313
+ }
8314
+ else if (varTypeIsFloating(baseType))
8315
+ {
8316
+ // Handle `(x >= NaN) == false` and `(NaN >= x) == false` for floating-point types
8317
+ if (VNIsVectorNaN(type, baseType, cnsVN))
8318
+ {
8319
+ return zeroVN;
8320
+ }
8321
+ }
8322
+ break;
8323
+ }
8324
+
8325
+ case GT_LT:
8326
+ {
8327
+ ValueNum zeroVN = VNZeroForType(type);
8328
+
8329
+ if (varTypeIsUnsigned(baseType))
8330
+ {
8331
+ // Handle `x < 0 == false` for unsigned types.
8332
+ if ((cnsVN == arg1VN) && (cnsVN == zeroVN))
8333
+ {
8334
+ return zeroVN;
8335
+ }
8336
+ }
8337
+ else if (varTypeIsFloating(baseType))
8338
+ {
8339
+ // Handle `(x < NaN) == false` and `(NaN < x) == false` for floating-point types
8340
+ if (VNIsVectorNaN(type, baseType, cnsVN))
8341
+ {
8342
+ return zeroVN;
8343
+ }
8344
+ }
8345
+ break;
8346
+ }
8347
+
8348
+ case GT_LE:
8349
+ {
8350
+ ValueNum zeroVN = VNZeroForType(type);
8351
+
8352
+ if (varTypeIsUnsigned(baseType))
8353
+ {
8354
+ // Handle `0 <= x == true` for unsigned types.
8355
+ if ((cnsVN == arg0VN) && (cnsVN == zeroVN))
8356
+ {
8357
+ return VNAllBitsForType(type);
8358
+ }
8359
+ }
8360
+ else if (varTypeIsFloating(baseType))
8361
+ {
8362
+ // Handle `(x <= NaN) == false` and `(NaN <= x) == false` for floating-point types
8363
+ if (VNIsVectorNaN(type, baseType, cnsVN))
8364
+ {
8365
+ return zeroVN;
8366
+ }
8367
+ }
8368
+ break;
8369
+ }
8370
+
8266
8371
case GT_MUL:
8267
8372
{
8268
8373
if (!varTypeIsFloating(baseType))
@@ -8310,6 +8415,19 @@ ValueNum ValueNumStore::EvalHWIntrinsicFunBinary(GenTreeHWIntrinsic* tree,
8310
8415
break;
8311
8416
}
8312
8417
8418
+ case GT_NE:
8419
+ {
8420
+ if (varTypeIsFloating(baseType))
8421
+ {
8422
+ // Handle `(x != NaN) == true` and `(NaN != x) == true` for floating-point types
8423
+ if (VNIsVectorNaN(type, baseType, cnsVN))
8424
+ {
8425
+ return VNAllBitsForType(type);
8426
+ }
8427
+ }
8428
+ break;
8429
+ }
8430
+
8313
8431
case GT_OR:
8314
8432
{
8315
8433
// Handle `x | 0 == x` and `0 | x == x`
@@ -8477,6 +8595,48 @@ ValueNum ValueNumStore::EvalHWIntrinsicFunBinary(GenTreeHWIntrinsic* tree,
8477
8595
}
8478
8596
#endif
8479
8597
8598
+ case NI_Vector128_op_Equality:
8599
+ #if defined(TARGET_ARM64)
8600
+ case NI_Vector64_op_Equality:
8601
+ #elif defined(TARGET_XARCH)
8602
+ case NI_Vector256_op_Equality:
8603
+ case NI_Vector512_op_Equality:
8604
+ #endif // !TARGET_ARM64 && !TARGET_XARCH
8605
+ {
8606
+ if (varTypeIsFloating(baseType))
8607
+ {
8608
+ // Handle `(x == NaN) == false` and `(NaN == x) == false` for floating-point types
8609
+ var_types simdType = Compiler::getSIMDTypeForSize(simdSize);
8610
+
8611
+ if (VNIsVectorNaN(simdType, baseType, cnsVN))
8612
+ {
8613
+ return VNZeroForType(type);
8614
+ }
8615
+ }
8616
+ break;
8617
+ }
8618
+
8619
+ case NI_Vector128_op_Inequality:
8620
+ #if defined(TARGET_ARM64)
8621
+ case NI_Vector64_op_Inequality:
8622
+ #elif defined(TARGET_XARCH)
8623
+ case NI_Vector256_op_Inequality:
8624
+ case NI_Vector512_op_Inequality:
8625
+ #endif // !TARGET_ARM64 && !TARGET_XARCH
8626
+ {
8627
+ if (varTypeIsFloating(baseType))
8628
+ {
8629
+ // Handle `(x != NaN) == true` and `(NaN != x) == true` for floating-point types
8630
+ var_types simdType = Compiler::getSIMDTypeForSize(simdSize);
8631
+
8632
+ if (VNIsVectorNaN(simdType, baseType, cnsVN))
8633
+ {
8634
+ return VNOneForType(type);
8635
+ }
8636
+ }
8637
+ break;
8638
+ }
8639
+
8480
8640
default:
8481
8641
{
8482
8642
break;
@@ -8505,6 +8665,32 @@ ValueNum ValueNumStore::EvalHWIntrinsicFunBinary(GenTreeHWIntrinsic* tree,
8505
8665
return arg0VN;
8506
8666
}
8507
8667
8668
+ case GT_EQ:
8669
+ case GT_GE:
8670
+ case GT_LE:
8671
+ {
8672
+ // We can't handle floating-point due to NaN
8673
+
8674
+ if (varTypeIsIntegral(baseType))
8675
+ {
8676
+ return VNAllBitsForType(type);
8677
+ }
8678
+ break;
8679
+ }
8680
+
8681
+ case GT_GT:
8682
+ case GT_LT:
8683
+ case GT_NE:
8684
+ {
8685
+ // We can't handle floating-point due to NaN
8686
+
8687
+ if (varTypeIsIntegral(baseType))
8688
+ {
8689
+ return VNZeroForType(type);
8690
+ }
8691
+ break;
8692
+ }
8693
+
8508
8694
case GT_OR:
8509
8695
{
8510
8696
// Handle `x | x == x`
@@ -8532,6 +8718,48 @@ ValueNum ValueNumStore::EvalHWIntrinsicFunBinary(GenTreeHWIntrinsic* tree,
8532
8718
default:
8533
8719
break;
8534
8720
}
8721
+
8722
+ switch (ni)
8723
+ {
8724
+ case NI_Vector128_op_Equality:
8725
+ #if defined(TARGET_ARM64)
8726
+ case NI_Vector64_op_Equality:
8727
+ #elif defined(TARGET_XARCH)
8728
+ case NI_Vector256_op_Equality:
8729
+ case NI_Vector512_op_Equality:
8730
+ #endif // !TARGET_ARM64 && !TARGET_XARCH
8731
+ {
8732
+ // We can't handle floating-point due to NaN
8733
+
8734
+ if (varTypeIsIntegral(baseType))
8735
+ {
8736
+ return VNOneForType(type);
8737
+ }
8738
+ break;
8739
+ }
8740
+
8741
+ case NI_Vector128_op_Inequality:
8742
+ #if defined(TARGET_ARM64)
8743
+ case NI_Vector64_op_Inequality:
8744
+ #elif defined(TARGET_XARCH)
8745
+ case NI_Vector256_op_Inequality:
8746
+ case NI_Vector512_op_Inequality:
8747
+ #endif // !TARGET_ARM64 && !TARGET_XARCH
8748
+ {
8749
+ // We can't handle floating-point due to NaN
8750
+
8751
+ if (varTypeIsIntegral(baseType))
8752
+ {
8753
+ return VNZeroForType(type);
8754
+ }
8755
+ break;
8756
+ }
8757
+
8758
+ default:
8759
+ {
8760
+ break;
8761
+ }
8762
+ }
8535
8763
}
8536
8764
8537
8765
if (encodeResultType)
0 commit comments