[llvm] [KnownFPClass] Add KnownFPClass deductions for `pow` (PR #215592)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 08:53:13 PDT 2026


================
@@ -1610,6 +1567,33 @@ void GISelValueTracking::computeKnownFPClass(Register R,
     Known = KnownFPClass::log(KnownSrc, Mode);
     break;
   }
+  case TargetOpcode::G_FPOW: {
+    if ((InterestedClasses & (fcNan | fcNegative)) == fcNone)
+      break;
+
+    FPClassTest InterestedLHS = fcNone;
+    FPClassTest InterestedRHS = fcNone;
+    if (InterestedClasses & fcNan) {
+      // pow may return NaN if one of the arguments is NaN. NaN may be produced
+      // from a non-zero-finite-negative base and a non-integer exponent.
+      InterestedLHS |= fcNan | fcNegNormal | fcNegSubnormal;
+      InterestedRHS |= fcNan;
+    }
+    if (InterestedClasses & fcNegative) {
+      // A negative result requires both a negative base and an odd integer
+      // exponent. Only normal values can be odd integers.
+      InterestedLHS |= fcNegative;
+      InterestedRHS |= fcNormal;
+    }
+
+    KnownFPClass KnownLHS, KnownRHS;
+    computeKnownFPClass(MI.getOperand(1).getReg(), DemandedElts, InterestedLHS,
+                        KnownLHS, Depth + 1);
+    computeKnownFPClass(MI.getOperand(2).getReg(), DemandedElts, InterestedRHS,
+                        KnownRHS, Depth + 1);
----------------
arsenm wrote:

Same 

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


More information about the llvm-commits mailing list