[llvm] [SPIR-V] Derive FPFastMathMode from nofpclass attributes on OpenCL builtins (PR #188984)
Dmitry Sidorov via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 30 05:06:38 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);
----------------
MrSidims wrote:
(I'm just imagining it, don't know for sure) both should be fine, `!!` is some very old-school idiom, that ensures, that no intermediate integer is created.
https://github.com/llvm/llvm-project/pull/188984
More information about the llvm-commits
mailing list