Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/flang
diff options
context:
space:
mode:
authorTom Eccles <tom.eccles@arm.com>2022-10-19 13:51:31 +0300
committerTom Eccles <tom.eccles@arm.com>2022-11-04 20:22:35 +0300
commitd0d4b635786d510cd919cadbeb7e5e19983242cf (patch)
tree38cd877bb2440c8befbdf38d4ce92b5e047ed07e /flang
parentc4dc3c029416a25103d631e8dc5422f65c076376 (diff)
[flang] add -f[no-]reciprocal-math
Only add the option processing and store the result. No attributes are added to FIR yet. Differential Revision: https://reviews.llvm.org/D137330
Diffstat (limited to 'flang')
-rw-r--r--flang/include/flang/Frontend/LangOptions.def2
-rw-r--r--flang/lib/Frontend/CompilerInvocation.cpp6
-rw-r--r--flang/test/Driver/driver-help-hidden.f901
-rw-r--r--flang/test/Driver/driver-help.f902
-rw-r--r--flang/test/Driver/flang_fp_opts.f902
-rw-r--r--flang/test/Driver/frontend-forwarding.f902
6 files changed, 15 insertions, 0 deletions
diff --git a/flang/include/flang/Frontend/LangOptions.def b/flang/include/flang/Frontend/LangOptions.def
index 059e3d18dfc8..024db6109d6a 100644
--- a/flang/include/flang/Frontend/LangOptions.def
+++ b/flang/include/flang/Frontend/LangOptions.def
@@ -31,6 +31,8 @@ LANGOPT(ApproxFunc, 1, false)
LANGOPT(NoSignedZeros, 1, false)
/// Allow reassociation transformations for floating-point instructions
LANGOPT(AssociativeMath, 1, false)
+/// Allow division operations to be reassociated
+LANGOPT(ReciprocalMath, 1, false)
#undef LANGOPT
#undef ENUM_LANGOPT
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 8c0bdcd185b6..bb87ea285a26 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -726,6 +726,12 @@ static bool parseFloatingPointArgs(CompilerInvocation &invoc,
opts.AssociativeMath = true;
}
+ if (const llvm::opt::Arg *a =
+ args.getLastArg(clang::driver::options::OPT_freciprocal_math)) {
+ diags.Report(diagUnimplemented) << a->getOption().getName();
+ opts.ReciprocalMath = true;
+ }
+
return true;
}
diff --git a/flang/test/Driver/driver-help-hidden.f90 b/flang/test/Driver/driver-help-hidden.f90
index b3913e99d138..3bce2a57caa1 100644
--- a/flang/test/Driver/driver-help-hidden.f90
+++ b/flang/test/Driver/driver-help-hidden.f90
@@ -48,6 +48,7 @@
! CHECK-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros
! CHECK-NEXT: -fopenacc Enable OpenACC
! CHECK-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code.
+! CHECK-NEXT: -freciprocal-math Allow division operations to be reassociated
! CHECK-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages
! CHECK-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
! CHECK-NEXT: -help Display available options
diff --git a/flang/test/Driver/driver-help.f90 b/flang/test/Driver/driver-help.f90
index 32b6f7615dec..8d24deee0b1a 100644
--- a/flang/test/Driver/driver-help.f90
+++ b/flang/test/Driver/driver-help.f90
@@ -46,6 +46,7 @@
! HELP-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros
! HELP-NEXT: -fopenacc Enable OpenACC
! HELP-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code.
+! HELP-NEXT: -freciprocal-math Allow division operations to be reassociated
! HELP-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages
! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
! HELP-NEXT: -help Display available options
@@ -128,6 +129,7 @@
! HELP-FC1-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros
! HELP-FC1-NEXT: -fopenacc Enable OpenACC
! HELP-FC1-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code.
+! HELP-FC1-NEXT: -freciprocal-math Allow division operations to be reassociated
! HELP-FC1-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages
! HELP-FC1-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
! HELP-FC1-NEXT: -help Display available options
diff --git a/flang/test/Driver/flang_fp_opts.f90 b/flang/test/Driver/flang_fp_opts.f90
index bbe886bcec87..0dc31f6f7649 100644
--- a/flang/test/Driver/flang_fp_opts.f90
+++ b/flang/test/Driver/flang_fp_opts.f90
@@ -7,6 +7,7 @@
! RUN: -fapprox-func \
! RUN: -fno-signed-zeros \
! RUN: -mreassociate \
+! RUN: -freciprocal-math \
! RUN: %s 2>&1 | FileCheck %s
! CHECK: ffp-contract= is not currently implemented
! CHECK: menable-no-infs is not currently implemented
@@ -14,3 +15,4 @@
! CHECK: fapprox-func is not currently implemented
! CHECK: fno-signed-zeros is not currently implemented
! CHECK: mreassociate is not currently implemented
+! CHECK: freciprocal-math is not currently implemented
diff --git a/flang/test/Driver/frontend-forwarding.f90 b/flang/test/Driver/frontend-forwarding.f90
index de3ed6ddbfca..9d1d7cb8d3c8 100644
--- a/flang/test/Driver/frontend-forwarding.f90
+++ b/flang/test/Driver/frontend-forwarding.f90
@@ -14,6 +14,7 @@
! RUN: -fapprox-func \
! RUN: -fno-signed-zeros \
! RUN: -fassociative-math \
+! RUN: -freciprocal-math \
! RUN: -mllvm -print-before-all\
! RUN: -P \
! RUN: | FileCheck %s
@@ -30,5 +31,6 @@
! CHECK: "-fapprox-func"
! CHECK: "-fno-signed-zeros"
! CHECK: "-mreassociate"
+! CHECK: "-freciprocal-math"
! CHECK: "-fconvert=little-endian"
! CHECK: "-mllvm" "-print-before-all"