From 13cc256e404620c1de0cbcc4e43ce1e2dbbc4898 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 2 Dec 2012 13:20:44 +0000 Subject: Vendor import of clang release_32 branch r168974 (effectively, 3.2 RC2): http://llvm.org/svn/llvm-project/cfe/branches/release_32@168974 --- test/CodeGen/fp-contract-pragma.cpp | 64 +++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 test/CodeGen/fp-contract-pragma.cpp (limited to 'test/CodeGen/fp-contract-pragma.cpp') diff --git a/test/CodeGen/fp-contract-pragma.cpp b/test/CodeGen/fp-contract-pragma.cpp new file mode 100644 index 000000000000..afd8c43121e6 --- /dev/null +++ b/test/CodeGen/fp-contract-pragma.cpp @@ -0,0 +1,64 @@ +// RUN: %clang_cc1 -O3 -emit-llvm -o - %s | FileCheck %s + +// Is FP_CONTRACT is 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; +} + +// Is FP_CONTRACT state cleared on exiting compound statements? +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 ON + } + return a * b + c; +} + +// Does FP_CONTRACT survive template instatiation? +class Foo {}; +Foo operator+(Foo, Foo); + +template +T template_muladd(T a, T b, T c) { + #pragma STDC FP_CONTRACT ON + return a * b + c; +} + +float fp_contract_3(float a, float b, float c) { +// CHECK: _Z13fp_contract_3fff +// CHECK: tail call float @llvm.fmuladd + return template_muladd(a, b, c); +} + +template class fp_contract_4 { + float method(float a, float b, float c) { + #pragma STDC FP_CONTRACT ON + return a * b + c; + } +}; + +template class fp_contract_4; +// CHECK: _ZN13fp_contract_4IiE6methodEfff +// CHECK: tail call float @llvm.fmuladd + +// Check file-scoped FP_CONTRACT +#pragma STDC FP_CONTRACT ON +float fp_contract_5(float a, float b, float c) { +// CHECK: _Z13fp_contract_5fff +// CHECK: tail call float @llvm.fmuladd + return a * b + c; +} + +#pragma STDC FP_CONTRACT OFF +float fp_contract_6(float a, float b, float c) { +// CHECK: _Z13fp_contract_6fff +// CHECK: %[[M:.+]] = fmul float %a, %b +// CHECK-NEXT: fadd float %[[M]], %c + return a * b + c; +} + -- cgit v1.2.3