[PATCH] D136080: [flang] Add -ffp-contract option processing

Slava Zakharin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 19 11:53:56 PDT 2022


vzakhari added inline comments.


================
Comment at: flang/include/flang/Frontend/LangOptions.h:29
+
+    // Enable the floating point pragma
+    FPM_On,
----------------
tblah wrote:
> awarzynski wrote:
> > What are these pragmas? Perhaps you can add a test that would include them?
> I copied this comment from clang. I believe the pragma is 
> ```
> #pragma clang fp contract(fast)
> ```
> 
> See https://clang.llvm.org/docs/LanguageExtensions.html#extensions-to-specify-floating-point-flags
> 
> This patch only adds support for argument processing, so I can't test for the pragmas.
I do not think we should blindly copy this from clang.  I believe `-ffp-contract=on`  is there to do the contraction complying to the language standard - but Fortran standard says nothing about contraction.  I am also not aware about a Fortran compiler that supports directives related to contraction, so `fast-honor-pragmas` does not seem to be applicable as well.  Basically, we end up with just `off` and `fast`.

Now, it may be reasonable to support the same `-ffp-contract=` arguments so that users can apply the same options sets for C/C++ and Fortran compilations.  If we want to do this, we need to map `on` and `fast-honor-pragmas` to something, e.g. `fast`.  A driver warning (not an error) may be useful to make the option's behavior clear when `on` and `fast-honor-pragmas` are passed.


================
Comment at: flang/test/Driver/driver-help-hidden.f90:34
 ! CHECK-NEXT: Use <value> as character line width in fixed mode
+! CHECK-NEXT: -ffp-contract=<value> Form fused FP ops (e.g. FMAs): fast (fuses across statements disregarding pragmas) | on (only fuses in the same statement unless dictated by pragmas) | off (never fuses) | fast-honor-pragmas (fuses across statements unless diectated by pragmas). Default is 'fast' for CUDA, 'fast-honor-pragmas' for HIP, and 'on' otherwise.
 ! CHECK-NEXT: -ffree-form            Process source files in free form
----------------
Is it easy to emit a different help message for Flang to say that there are only two modes for Fortran?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136080/new/

https://reviews.llvm.org/D136080



More information about the cfe-commits mailing list