[llvm] expandIS_FPCLASS: Support fcNegative and fcPositive (PR #184788)
YunQiang Su via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 8 19:27:39 PDT 2026
================
@@ -9306,6 +9306,67 @@ SDValue TargetLowering::expandIS_FPCLASS(EVT ResultVT, SDValue Op,
// Tests that involve more than one class should be processed first.
SDValue PartialRes;
+ // Handle sign bit tests first (fcPositive/fcNegative).
+ // These test only the sign bit, if not NaN.
+ // On 32-bit platforms with 64-bit floats, we need to be careful about
+ // integer comparisons. We use FP_ROUND to convert to a smaller float type
+ // that matches ResultVT's size, then compare with 0.
+ if (Test == fcPositive || Test == fcNegative) {
+ SDValue SignBitResult;
+ unsigned MaxLegalIntBits = 32;
+ if (isTypeLegal(MVT::i64))
+ MaxLegalIntBits = 64;
+
+ unsigned IntVTBits = IntVT.getScalarSizeInBits();
+ bool NeedFPCompare = IntVTBits > MaxLegalIntBits;
+
+ if (NeedFPCompare) {
+ // Truncate to the largest legal float type.
+ EVT TruncFloatEltVT = EVT::getFloatingPointVT(MaxLegalIntBits);
----------------
wzssyqa wrote:
In fact, we don't: we use
```
isOperationLegalOrCustom(ISD::FP_ROUND, TruncFloatVT)
```
later.
https://github.com/llvm/llvm-project/pull/184788
More information about the llvm-commits
mailing list