bool f() {
return __FLT_EVAL_METHOD__ < 0 &&
__FLT_EVAL_METHOD__ == -1;
}
float fp_precise_1(float a, float b, float c) {
#pragma float_control(precise, off)
return a * b + c;
}
float fp_precise_2(float a, float b, float c) {
{
#pragma float_control(precise, off)
}
return a * b + c;
}
class Foo {};
Foo operator+(Foo, Foo);
template <typename T>
T template_muladd(T a, T b, T c) {
#pragma float_control(precise, off)
return a * b + c;
}
float fp_precise_3(float a, float b, float c) {
return template_muladd<float>(a, b, c);
}
template <typename T>
class fp_precise_4 {
float method(float a, float b, float c) {
#pragma float_control(precise, off)
return a * b + c;
}
};
template class fp_precise_4<int>;
#pragma float_control(push)
#pragma float_control(precise, off)
float fp_precise_5(float a, float b, float c) {
return a * b + c;
}
#pragma float_control(pop)
float fff(float x, float y) {
#pragma float_control(except, on)
float z;
z = z * z;
{
z = x * y;
}
{
#pragma float_control(except, off)
z = z + x * y;
}
z = z * z;
return z;
}
float check_precise(float x, float y) {
float z;
{
#pragma float_control(precise, on)
z = x * y + z;
}
{
#pragma float_control(precise, off)
z = x * y + z;
}
return z;
}
float fma_test2(float a, float b, float c) {
#pragma float_control(precise, off)
float x = a * b + c;
return x;
}
float fma_test1(float a, float b, float c) {
#pragma float_control(precise, on)
float x = a * b + c;
return x;
}
#pragma float_control(push)
#pragma float_control(precise, on)
struct Distance {};
Distance operator+(Distance, Distance);
template <class T>
T add(T lhs, T rhs) {
#pragma float_control(except, on)
return lhs + rhs;
}
#pragma float_control(pop)
float test_OperatorCall() {
return add(1.0f, 2.0f);
}
#if FENV_ON
#pragma STDC FENV_ACCESS ON
#endif
void callt() {
volatile float z;
z = z * z;
}
float myAdd(int i, float f) {
if (i<0)
return 1.0 + 2.0;
static double v = 1.0 / 3.0;
return v;
}
#if EXCEPT
namespace ns {
#pragma float_control(except, on, push)
float exc_on(double x, float zero) {
{} try {
x = 1.0 / zero;
} catch (...) {}
return zero;
}
}
float exc_still_on(double x, float zero) {
{} try {
x = 1.0 / zero;
} catch (...) {}
return zero;
}
#pragma float_control(pop)
float exc_off(double x, float zero) {
{} try {
x = 1.0 / zero;
} catch (...) {}
return zero;
}
namespace fc_template_namespace {
#pragma float_control(except, on, push)
template <class T>
T exc_on(double x, T zero) {
{} try {
x = 1.0 / zero;
} catch (...) {}
return zero;
}
}
#pragma float_control(pop)
float xx(double x, float z) {
return fc_template_namespace::exc_on<float>(x, z);
}
#endif
float try_lam(float x, unsigned n) {
float result;
auto t =
[](float a, float b) {
#pragma float_control( except, on)
return a * b;
} (1.0f,2.0f);
result = x + t;
return result;
}
float mySub(float x, float y) {
return x - y;
}
float mySubSource(float x, float y) {
#pragma clang fp eval_method(source)
return x - y;
}
float mySubExtended(float x, float y) {
#pragma clang fp eval_method(extended)
return x - y;
}
float mySubDouble(float x, float y) {
#pragma clang fp eval_method(double)
return x - y;
}
#ifndef NF128
__float128 mySub128(__float128 x, __float128 y) {
return x - y;
}
#endif
void mySubfp16(__fp16 *res, __fp16 *x, __fp16 *y) {
*res = *x - *y;
}
float Div(float x, float y, float z) {
return x / (y / z);
}
float DivExtended(float x, float y, float z) {
#pragma clang fp eval_method(extended)
return x / (y / z);
}
float DivDouble(float x, float y, float z) {
#pragma clang fp eval_method(double)
return x / (y / z);
}
float DivSource(float x, float y, float z) {
#pragma clang fp eval_method(source)
return x / (y / z);
}
int main() {
float f = Div(4.2f, 1.0f, 3.0f);
float fextended = DivExtended(4.2f, 1.0f, 3.0f);
float fdouble = DivDouble(4.2f, 1.0f, 3.0f);
float fsource = DivSource(4.2f, 1.0f, 3.0f);
}