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, 9 insertions, 15 deletions
diff --git a/clang/test/CodeGen/fp-contract-pragma.cpp b/clang/test/CodeGen/fp-contract-pragma.cpp index ceedfd25e48..1c5921a53f9 100644 --- a/clang/test/CodeGen/fp-contract-pragma.cpp +++ b/clang/test/CodeGen/fp-contract-pragma.cpp @@ -1,9 +1,10 @@ // RUN: %clang_cc1 -O3 -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s -// Is FP_CONTRACT on by default, at least at -O3? -float fp_contract_8(float a, float b, float c) { -// CHECK: _Z13fp_contract_8fff +// Is FP_CONTRACT honored in a simple case? +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; } @@ -12,7 +13,6 @@ 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,6 +20,8 @@ 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) { @@ -60,23 +62,15 @@ 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& d_passed_by_ref) { +float fp_contract_7(float a, float b, float c) { // CHECK: _Z13fp_contract_7fff // CHECK: %[[M:.+]] = fmul float %b, 2.000000e+00 +// CHECK-NEXT: fsub float %[[M]], %c #pragma STDC FP_CONTRACT ON - return (d_passed_by_ref = 2 * b) - c; + return (a = 2 * b) - c; } |