1 // RUN: %clang_cc1 -S -emit-llvm -triple i386-linux -std=c++2a -Wno-unknown-pragmas %s -o - | FileCheck %s
3 // nextUp(1.F) == 0x1.000002p0F
5 constexpr float add_round_down(float x
, float y
) {
6 #pragma STDC FENV_ROUND FE_DOWNWARD
12 constexpr float add_round_up(float x
, float y
) {
13 #pragma STDC FENV_ROUND FE_UPWARD
19 float V1
= add_round_down(1.0F
, 0x0.000001p0F
);
20 float V2
= add_round_up(1.0F
, 0x0.000001p0F
);
21 // CHECK: @V1 = {{.*}} float 1.000000e+00
22 // CHECK: @V2 = {{.*}} float 0x3FF0000020000000
24 constexpr float add_cast_round_down(float x
, double y
) {
25 #pragma STDC FENV_ROUND FE_DOWNWARD
31 constexpr float add_cast_round_up(float x
, double y
) {
32 #pragma STDC FENV_ROUND FE_UPWARD
38 float V3
= add_cast_round_down(1.0F
, 0x0.000001p0F
);
39 float V4
= add_cast_round_up(1.0F
, 0x0.000001p0F
);
41 // CHECK: @V3 = {{.*}} float 1.000000e+00
42 // CHECK: @V4 = {{.*}} float 0x3FF0000020000000
44 // The next three variables use the same function as initializer, only rounding
47 float V5
= []() -> float {
48 return [](float x
, float y
)->float {
49 #pragma STDC FENV_ROUND FE_UPWARD
51 }([](float x
, float y
) -> float {
52 #pragma STDC FENV_ROUND FE_UPWARD
54 }(1.0F
, 0x0.000001p0F
),
57 // CHECK: @V5 = {{.*}} float 0x3FF0000040000000
59 float V6
= []() -> float {
60 return [](float x
, float y
)->float {
61 #pragma STDC FENV_ROUND FE_DOWNWARD
63 }([](float x
, float y
) -> float {
64 #pragma STDC FENV_ROUND FE_UPWARD
66 }(1.0F
, 0x0.000001p0F
),
69 // CHECK: @V6 = {{.*}} float 0x3FF0000020000000
71 float V7
= []() -> float {
72 return [](float x
, float y
)->float {
73 #pragma STDC FENV_ROUND FE_DOWNWARD
75 }([](float x
, float y
) -> float {
76 #pragma STDC FENV_ROUND FE_DOWNWARD
78 }(1.0F
, 0x0.000001p0F
),
81 // CHECK: @V7 = {{.*}} float 1.000000e+00