[llvm-branch-commits] [llvm] InstCombine: Handle fptrunc in SimplifyDemandedFPClass (PR #175421)

Yingwei Zheng via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Jan 11 02:50:23 PST 2026


================
@@ -2033,6 +2033,36 @@ static Constant *getFPClassConstant(Type *Ty, FPClassTest Mask,
   }
 }
 
+static Value *simplifyDemandedUseFPClassFPTrunc(InstCombinerImpl &IC,
+                                                Instruction &I,
+                                                FPClassTest DemandedMask,
+                                                KnownFPClass &Known,
+                                                unsigned Depth) {
+  FPClassTest SrcDemandedMask = DemandedMask;
+
+  // Zero results may have been rounded from subnormal sources.
+  if (DemandedMask & fcNegZero)
+    SrcDemandedMask |= fcNegSubnormal;
+  if (DemandedMask & fcPosZero)
+    SrcDemandedMask |= fcPosSubnormal;
+
+  // Subnormal results may have been normal in the source type
+  if (DemandedMask & fcNegSubnormal)
+    SrcDemandedMask |= fcNegNormal;
+  if (DemandedMask & fcPosSubnormal)
+    SrcDemandedMask |= fcPosNormal;
+
----------------
dtcxzyw wrote:

Missing path from normal to inf.

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


More information about the llvm-branch-commits mailing list