[clang] [NFC] Add assertion to ensure FiniteMathOnly is in sync with HonorINFs and HonorNANs. (PR #97342)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 10 06:56:15 PDT 2024


================
@@ -816,6 +816,11 @@ class FPOptions {
     setAllowFPReassociate(LO.AllowFPReassoc);
     setNoHonorNaNs(LO.NoHonorNaNs);
     setNoHonorInfs(LO.NoHonorInfs);
+    // Ensure that if FiniteMathOnly is enabled, NoHonorNaNs and NoHonorInfs are
+    // also enabled. This is because FiniteMathOnly mode assumes no NaNs or Infs
+    // are present in computations.
+    assert((LO.FiniteMathOnly == (LO.NoHonorInfs && LO.NoHonorNaNs)) &&
----------------
AaronBallman wrote:

Correct, that assertion can go away (don't forget to update the PR title and summary accordingly as well).

>  I suppose CLFiniteMathOnly should be removed too, right?

CC @AnastasiaStulova as OpenCL code owner.

I think `CLFiniteMathOnly` is a combination of `NoHonorInfs`, `NoHonorNaNs`, and `OpenCL` language mode. However, I don't see `CLFiniteMathOnly` being *used* by anything when I grep over the source. We set the flag from Options.td via marshaling, but we don't seem to ever check the value of the LangOpt anywhere. So it seems like `CLFiniteMathOnly` can be removed and maybe `-cl-finite-math-only` could be deprecated and eventually removed?

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


More information about the cfe-commits mailing list