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

Dmitry Sidorov via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 27 09:12:57 PDT 2026


================
@@ -1279,6 +1279,25 @@ 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 (const Function *F = CB.getCalledFunction()) {
----------------
MrSidims wrote:

We must check, what SPIR-V version is set to be allowed. It's invalid to apply FPFastMathMode decoration to ExtInst before SPIR-V 1.6. Please add this check and cover it with negative test.

Also per https://registry.khronos.org/SPIR-V/specs/unified1/OpenCL.ExtendedInstructionSet.100.html only math builtins can be decorated. Not sure if we can check it properly here.

Please also check GLSL spec if it allows fast math on any of the builtins. If yes - add appropriate test. If not - please guard shader compilation from this check and add a negative test.

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


More information about the llvm-commits mailing list