[llvm] [SPIR-V] Derive FPFastMathMode from nofpclass attributes on OpenCL builtins (PR #188984)

Arseniy Obolenskiy via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 30 01:51:53 PDT 2026


================
@@ -1279,6 +1279,28 @@ static bool generateExtInst(const SPIRV::IncomingCall *Call,
     MIB.getInstr()->setFlag(MachineInstr::MIFlag::FmNoNans);
     MIB.getInstr()->setFlag(MachineInstr::MIFlag::FmNoInfs);
   }
+
+  // Derive fast-math flags from nofpclass attributes on the called function.
+  if (ST.isKernel() &&
+      ST.canUseExtension(SPIRV::Extension::SPV_KHR_float_controls2)) {
+    if (const Function *F = CB.getCalledFunction()) {
+      bool AddNoNan = !!(CB.getRetNoFPClass() & fcNan);
+      bool AddNoInf = !!(CB.getRetNoFPClass() & fcInf);
+      for (unsigned I = 0, E = F->getFunctionType()->getNumParams();
+           I != E && (AddNoNan || AddNoInf); ++I) {
+        if (!F->getFunctionType()->getParamType(I)->isFloatingPointTy())
+          continue;
----------------
aobolensk wrote:

Applied

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


More information about the llvm-commits mailing list