diff options
Diffstat (limited to 'clang/test/CodeGen/fp-contract-pragma.cpp')
| -rw-r--r-- | clang/test/CodeGen/fp-contract-pragma.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/clang/test/CodeGen/fp-contract-pragma.cpp b/clang/test/CodeGen/fp-contract-pragma.cpp index 1c5921a53f9..ceedfd25e48 100644 --- a/clang/test/CodeGen/fp-contract-pragma.cpp +++ b/clang/test/CodeGen/fp-contract-pragma.cpp @@ -1,10 +1,9 @@ // RUN: %clang_cc1 -O3 -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s -// Is FP_CONTRACT honored in a simple case? -float fp_contract_1(float a, float b, float c) { -// CHECK: _Z13fp_contract_1fff +// Is FP_CONTRACT on by default, at least at -O3? +float fp_contract_8(float a, float b, float c) { +// CHECK: _Z13fp_contract_8fff // CHECK: tail call float @llvm.fmuladd - #pragma STDC FP_CONTRACT ON return a * b + c; } @@ -13,6 +12,7 @@ float fp_contract_2(float a, float b, float c) { // CHECK: _Z13fp_contract_2fff // CHECK: %[[M:.+]] = fmul float %a, %b // CHECK-NEXT: fadd float %[[M]], %c + #pragma STDC FP_CONTRACT OFF { #pragma STDC FP_CONTRACT ON } @@ -20,8 +20,6 @@ float fp_contract_2(float a, float b, float c) { } // Does FP_CONTRACT survive template instantiation? -class Foo {}; -Foo operator+(Foo, Foo); template <typename T> T template_muladd(T a, T b, T c) { @@ -62,15 +60,23 @@ float fp_contract_6(float a, float b, float c) { return a * b + c; } +// Does FP_CONTRACT inside a function override the same in the file scope? +float fp_contract_1(float a, float b, float c) { +// CHECK: _Z13fp_contract_1fff +// CHECK: tail call float @llvm.fmuladd + #pragma STDC FP_CONTRACT ON + return a * b + c; +} + + // If the multiply has multiple uses, don't produce fmuladd. // This used to assert (PR25719): // https://llvm.org/bugs/show_bug.cgi?id=25719 -float fp_contract_7(float a, float b, float c) { +float fp_contract_7(float a, float b, float c, float& d_passed_by_ref) { // CHECK: _Z13fp_contract_7fff // CHECK: %[[M:.+]] = fmul float %b, 2.000000e+00 -// CHECK-NEXT: fsub float %[[M]], %c #pragma STDC FP_CONTRACT ON - return (a = 2 * b) - c; + return (d_passed_by_ref = 2 * b) - c; } |

