[clang] [clang][Driver] Restore -cl-fast-relaxed-math fast-math cascade at cc1 level (PR #211768)

Hardik Kumar via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 24 04:35:04 PDT 2026


================
@@ -3386,11 +3386,23 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
     A->claim();
   }
 
+  // -cl-fast-relaxed-math implies -ffast-math at the cc1 level (so that
+  // callers talking to cc1 directly, e.g. via CompilerInvocation, get the
+  // full fast-math cascade from a bare -cl-fast-relaxed-math). When the
+  // Driver determines NaNs/Infs should still be honored (because
+  // -fhonor-nans/-fhonor-infinities overrode -cl-fast-relaxed-math), it must
+  // explicitly cancel that cc1-level implication.
+  bool NeedsHonorOverride = Args.hasArg(options::OPT_cl_fast_relaxed_math);
+
   if (!HonorINFs)
     CmdArgs.push_back("-menable-no-infs");
+  else if (NeedsHonorOverride)
+    CmdArgs.push_back("-mno-enable-no-infs");
 
   if (!HonorNaNs)
     CmdArgs.push_back("-menable-no-nans");
+  else if (NeedsHonorOverride)
+    CmdArgs.push_back("-mno-enable-no-nans");
----------------
hardikxk wrote:

This looks fine although I still need to test it. Also I had tried something similar but from what I am aware of setting these options here usually don't have much effect as when cc1 is invoked and the tablegen Options are execute these get overriden by the flags triggered by `ffast-math` (the original issue).

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


More information about the cfe-commits mailing list