================
@@ -968,10 +968,7 @@ class FPOptionsOverride {
       setAllowFPContractAcrossStatement();
   }
 
-  void setDisallowOptimizations() {
-    setFPPreciseEnabled(true);
-    setDisallowFPContract();
-  }
+  void setDisallowOptimizations() { setFPPreciseEnabled(true); }
----------------
wjristow wrote:

Actually, instead of just removing the call to `setDisallowFPContract()`, we 
should instead explicitly set the FP Contraction state to "on" (which is the 
default at `-O0`).  That is, we should call 
`setAllowFPContractWithinStatement()`.

In particular, if the user is compiling with `-ffast-math`, then the FP 
Contraction state will be `-ffp-contract=fast` (allowing FMA across multiple 
statements).  And if they applied `optnone`, then by removing the call to 
`setDisallowFPContract()`, we would mistakenly leave that inter-statement FMA 
enabled.  By calling `setAllowFPContractWithinStatement()` we are explicitly 
setting it the equivalent of the command-line option `-ffp-contract=on`, which 
is the desired state of `-O0` (and `optnone`).

https://github.com/llvm/llvm-project/pull/91061
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to