summaryrefslogtreecommitdiff
path: root/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
diff options
context:
space:
mode:
authorMelanie Blower <melanie.blower@intel.com>2020-05-01 09:26:15 -0700
committerMelanie Blower <melanie.blower@intel.com>2020-05-01 10:03:30 -0700
commit69aacaf699922ffe0450f567e21208c10c84731f (patch)
treed497d3a99a0440c7f631ecf5a6f12878634c624e /clang/test/CodeGen/fp-floatcontrol-pragma.cpp
parentd805ab7d039d6f3e7a8f7ab92e84c9d42a51ef66 (diff)
Reapply "Add support for #pragma float_control" with improvements to
test cases Add support for #pragma float_control Reviewers: rjmccall, erichkeane, sepavloff Differential Revision: https://reviews.llvm.org/D72841 This reverts commit 85dc033caccaa6ab919d57f9759290be41240146, and makes corrections to the test cases that failed on buildbots.
Diffstat (limited to 'clang/test/CodeGen/fp-floatcontrol-pragma.cpp')
-rw-r--r--clang/test/CodeGen/fp-floatcontrol-pragma.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/clang/test/CodeGen/fp-floatcontrol-pragma.cpp b/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
new file mode 100644
index 000000000000..caaab3ca4f84
--- /dev/null
+++ b/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+float fff(float x, float y) {
+// CHECK-LABEL: define float @_Z3fffff{{.*}}
+// CHECK: entry
+#pragma float_control(except, on)
+ float z;
+ z = z * z;
+ //CHECK: llvm.experimental.constrained.fmul{{.*}}
+ {
+ z = x * y;
+ //CHECK: llvm.experimental.constrained.fmul{{.*}}
+ }
+ {
+// This pragma has no effect since if there are any fp intrin in the
+// function then all the operations need to be fp intrin
+#pragma float_control(except, off)
+ z = z + x * y;
+ //CHECK: llvm.experimental.constrained.fmul{{.*}}
+ }
+ z = z * z;
+ //CHECK: llvm.experimental.constrained.fmul{{.*}}
+ return z;
+}
+float check_precise(float x, float y) {
+ // CHECK-LABEL: define float @_Z13check_preciseff{{.*}}
+ float z;
+ {
+#pragma float_control(precise, on)
+ z = x * y + z;
+ //CHECK: llvm.fmuladd{{.*}}
+ }
+ {
+#pragma float_control(precise, off)
+ z = x * y + z;
+ //CHECK: fmul fast float
+ //CHECK: fadd fast float
+ }
+ return z;
+}
+float fma_test1(float a, float b, float c) {
+// CHECK-LABEL define float @_Z9fma_test1fff{{.*}}
+#pragma float_control(precise, on)
+ float x = a * b + c;
+ //CHECK: fmuladd
+ return x;
+}