kawashima-fj updated this revision to Diff 475979.
kawashima-fj added a comment.

Update a test to include the `ffast-math -ffp-model=fast` pattern.


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

https://reviews.llvm.org/D138109

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/fp-options-to-fast-math-flags.c
  clang/test/Driver/fast-math.c
  clang/test/Driver/fp-model.c

Index: clang/test/Driver/fp-model.c
===================================================================
--- clang/test/Driver/fp-model.c
+++ clang/test/Driver/fp-model.c
@@ -66,6 +66,10 @@
 // RUN:   | FileCheck --check-prefix=WARN10 %s
 // WARN10: warning: overriding '-ffp-model=strict' option with '-fdenormal-fp-math=preserve-sign,preserve-sign' [-Woverriding-t-option]
 
+// RUN: %clang -### -ffp-model=strict -fapprox-func -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN11 %s
+// WARN11: warning: overriding '-ffp-model=strict' option with '-fapprox-func' [-Woverriding-t-option]
+
 // RUN: %clang -### -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NOROUND %s
 // CHECK-NOROUND: "-cc1"
@@ -86,6 +90,7 @@
 // CHECK-FPM-FAST: "-cc1"
 // CHECK-FPM-FAST: "-menable-no-infs"
 // CHECK-FPM-FAST: "-menable-no-nans"
+// CHECK-FPM-FAST: "-fapprox-func"
 // CHECK-FPM-FAST: "-funsafe-math-optimizations"
 // CHECK-FPM-FAST: "-fno-signed-zeros"
 // CHECK-FPM-FAST: "-mreassociate"
@@ -126,3 +131,47 @@
 // CHECK-FEB-IGNORE: "-fno-rounding-math"
 // CHECK-FEB-IGNORE: "-ffp-exception-behavior=ignore"
 
+// RUN: %clang -### -nostdinc -ffast-math -ffp-model=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FASTMATH-FPM-FAST %s
+// CHECK-FASTMATH-FPM-FAST: "-cc1"
+// CHECK-FASTMATH-FPM-FAST: "-menable-no-infs"
+// CHECK-FASTMATH-FPM-FAST: "-menable-no-nans"
+// CHECK-FASTMATH-FPM-FAST: "-fapprox-func"
+// CHECK-FASTMATH-FPM-FAST: "-funsafe-math-optimizations"
+// CHECK-FASTMATH-FPM-FAST: "-fno-signed-zeros"
+// CHECK-FASTMATH-FPM-FAST: "-mreassociate"
+// CHECK-FASTMATH-FPM-FAST: "-freciprocal-math"
+// CHECK-FASTMATH-FPM-FAST: "-ffp-contract=fast"
+// CHECK-FASTMATH-FPM-FAST: "-fno-rounding-math"
+// CHECK-FASTMATH-FPM-FAST: "-ffast-math"
+// CHECK-FASTMATH-FPM-FAST: "-ffinite-math-only"
+
+// RUN: %clang -### -nostdinc -ffast-math -ffp-model=precise -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FASTMATH-FPM-PRECISE %s
+// CHECK-FASTMATH-FPM-PRECISE:     "-cc1"
+// CHECK-FASTMATH-FPM-PRECISE-NOT: "-menable-no-infs"
+// CHECK-FASTMATH-FPM-PRECISE-NOT: "-menable-no-nans"
+// CHECK-FASTMATH-FPM-PRECISE-NOT: "-fapprox-func"
+// CHECK-FASTMATH-FPM-PRECISE-NOT: "-funsafe-math-optimizations"
+// CHECK-FASTMATH-FPM-PRECISE-NOT: "-fno-signed-zeros"
+// CHECK-FASTMATH-FPM-PRECISE-NOT: "-mreassociate"
+// CHECK-FASTMATH-FPM-PRECISE-NOT: "-freciprocal-math"
+// CHECK-FASTMATH-FPM-PRECISE:     "-ffp-contract=on"
+// CHECK-FASTMATH-FPM-PRECISE:     "-fno-rounding-math"
+// CHECK-FASTMATH-FPM-PRECISE-NOT: "-ffast-math"
+// CHECK-FASTMATH-FPM-PRECISE-NOT: "-ffinite-math-only"
+
+// RUN: %clang -### -nostdinc -ffast-math -ffp-model=strict -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FASTMATH-FPM-STRICT %s
+// CHECK-FASTMATH-FPM-STRICT:     "-cc1"
+// CHECK-FASTMATH-FPM-STRICT-NOT: "-menable-no-infs"
+// CHECK-FASTMATH-FPM-STRICT-NOT: "-menable-no-nans"
+// CHECK-FASTMATH-FPM-STRICT-NOT: "-fapprox-func"
+// CHECK-FASTMATH-FPM-STRICT-NOT: "-funsafe-math-optimizations"
+// CHECK-FASTMATH-FPM-STRICT-NOT: "-fno-signed-zeros"
+// CHECK-FASTMATH-FPM-STRICT-NOT: "-mreassociate"
+// CHECK-FASTMATH-FPM-STRICT-NOT: "-freciprocal-math"
+// CHECK-FASTMATH-FPM-STRICT:     "-ffp-contract=off"
+// CHECK-FASTMATH-FPM-STRICT-NOT: "-fno-rounding-math"
+// CHECK-FASTMATH-FPM-STRICT-NOT: "-ffast-math"
+// CHECK-FASTMATH-FPM-STRICT-NOT: "-ffinite-math-only"
Index: clang/test/Driver/fast-math.c
===================================================================
--- clang/test/Driver/fast-math.c
+++ clang/test/Driver/fast-math.c
@@ -91,6 +91,16 @@
 // CHECK-APPROX-FUNC: "-cc1"
 // CHECK-APPROX-FUNC: "-fapprox-func"
 //
+// RUN: %clang -### -fno-fast-math -fapprox-func -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-FAST-MATH-APPROX-FUNC %s
+// CHECK-NO-FAST-MATH-APPROX-FUNC: "-cc1"
+// CHECK-NO-FAST-MATH-APPROX-FUNC: "-fapprox-func"
+//
+// RUN: %clang -### -fapprox-func -fno-fast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-APPROX-FUNC-NO-FAST-MATH %s
+// CHECK-APPROX-FUNC-NO-FAST-MATH: "-cc1"
+// CHECK-APPROX-FUNC-NO-FAST-MATH-NOT: "-fapprox-func"
+//
 // RUN: %clang -### -fmath-errno -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MATH-ERRNO %s
 // CHECK-MATH-ERRNO: "-cc1"
Index: clang/test/CodeGen/fp-options-to-fast-math-flags.c
===================================================================
--- clang/test/CodeGen/fp-options-to-fast-math-flags.c
+++ clang/test/CodeGen/fp-options-to-fast-math-flags.c
@@ -5,6 +5,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fno-signed-zeros -emit-llvm -o - %s | FileCheck -check-prefix CHECK-NO-SIGNED-ZEROS %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -mreassociate -emit-llvm -o - %s | FileCheck -check-prefix CHECK-REASSOC %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -freciprocal-math -emit-llvm -o - %s | FileCheck -check-prefix CHECK-RECIP %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fapprox-func -emit-llvm -o - %s | FileCheck -check-prefix CHECK-AFN %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -funsafe-math-optimizations -emit-llvm -o - %s | FileCheck -check-prefix CHECK-UNSAFE %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -ffast-math -emit-llvm -o - %s | FileCheck -check-prefix CHECK-FAST %s
 
@@ -35,6 +36,9 @@
 // CHECK-RECIP: [[CALL_RES:%.+]] = call arcp float @fn(float noundef {{%.+}})
 // CHECK-RECIP: {{%.+}} = fadd arcp float {{%.+}}, [[CALL_RES]]
 
+// CHECK-AFN: [[CALL_RES:%.+]] = call afn float @fn(float noundef {{%.+}})
+// CHECK-AFN: {{%.+}} = fadd afn float {{%.+}}, [[CALL_RES]]
+
 // CHECK-UNSAFE: [[CALL_RES:%.+]] = call reassoc nsz arcp afn float @fn(float noundef {{%.+}})
 // CHECK-UNSAFE: {{%.+}} = fadd reassoc nsz arcp afn float {{%.+}}, [[CALL_RES]]
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2808,6 +2808,7 @@
       // If -ffp-model= is seen, reset to fno-fast-math
       HonorINFs = true;
       HonorNaNs = true;
+      ApproxFunc = false;
       // Turning *off* -ffast-math restores the toolchain default.
       MathErrno = TC.IsMathErrnoDefault();
       AssociativeMath = false;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to