[llvm] [KnownFPClass] Fix `KnownFPClass::log` deductions for ppcf128 (PR #223296)

Eric Ross via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 13 20:37:51 PDT 2026


================
@@ -3173,13 +3173,25 @@ Value *InstCombinerImpl::SimplifyDemandedUseFPClass(Instruction *I,
     case Intrinsic::log:
     case Intrinsic::log2:
     case Intrinsic::log10: {
+      Type *EltTy = VTy->getScalarType();
+      bool IsKnownNeverMultiUnitFPType = !EltTy->isMultiUnitFPType();
+
       FPClassTest DemandedSrcMask = DemandedMask & (fcNan | fcPosInf);
       if (DemandedMask & fcNan)
         DemandedSrcMask |= fcNan;
 
-      Type *EltTy = VTy->getScalarType();
       DenormalMode Mode = F.getDenormalMode(EltTy->getFltSemantics());
 
+      // log(x) can be negative zero or subnormal if x is close to +1.0 for the
+      // PPCDoubleDouble type.
+      if (!IsKnownNeverMultiUnitFPType &&
+          (DemandedMask & (fcNegZero | fcSubnormal))) {
+        DemandedSrcMask |= fcPosNormal;
+        // Note that DoubleAPFloat::isDenormal considers 1.0 + DBL_TRUE_MIN to
+        // be denormal, which APFloat::classify treats as fcSubnormal.
+        DemandedSrcMask |= fcPosSubnormal;
----------------
ZERICO2005 wrote:

Adding additional classes to `DemandedSrcMask` will not cause any incorrect deductions to be made.

https://github.com/llvm/llvm-project/pull/223296


More information about the llvm-commits mailing list