Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / AST / Interp / const-fpfeatures.cpp
blobe242108100258b5f109cfc7e6889f5b5402bb5b4
1 // RUN: %clang_cc1 -S -emit-llvm -triple i386-linux -std=c++2a -Wno-unknown-pragmas %s -o - | FileCheck %s
2 // RUN: %clang_cc1 -S -emit-llvm -triple i386-linux -fexperimental-new-constant-interpreter -std=c++2a -Wno-unknown-pragmas %s -o - | FileCheck %s
5 #pragma STDC FENV_ROUND FE_UPWARD
7 float F1u = 1.0F + 0x0.000002p0F;
8 float F2u = 1.0F + 0x0.000001p0F;
9 float F3u = 0x1.000001p0;
10 // CHECK: @F1u = {{.*}} float 0x3FF0000020000000
11 // CHECK: @F2u = {{.*}} float 0x3FF0000020000000
12 // CHECK: @F3u = {{.*}} float 0x3FF0000020000000
14 float FI1u = 0xFFFFFFFFU;
15 // CHECK: @FI1u = {{.*}} float 0x41F0000000000000
17 #pragma STDC FENV_ROUND FE_DOWNWARD
19 float F1d = 1.0F + 0x0.000002p0F;
20 float F2d = 1.0F + 0x0.000001p0F;
21 float F3d = 0x1.000001p0;
23 // CHECK: @F1d = {{.*}} float 0x3FF0000020000000
24 // CHECK: @F2d = {{.*}} float 1.000000e+00
25 // CHECK: @F3d = {{.*}} float 1.000000e+00
28 float FI1d = 0xFFFFFFFFU;
29 // CHECK: @FI1d = {{.*}} float 0x41EFFFFFE0000000
31 // nextUp(1.F) == 0x1.000002p0F
33 constexpr float add_round_down(float x, float y) {
34 #pragma STDC FENV_ROUND FE_DOWNWARD
35 float res = x;
36 res = res + y;
37 return res;
40 constexpr float add_round_up(float x, float y) {
41 #pragma STDC FENV_ROUND FE_UPWARD
42 float res = x;
43 res = res + y;
44 return res;
47 float V1 = add_round_down(1.0F, 0x0.000001p0F);
48 float V2 = add_round_up(1.0F, 0x0.000001p0F);
49 // CHECK: @V1 = {{.*}} float 1.000000e+00
50 // CHECK: @V2 = {{.*}} float 0x3FF0000020000000
53 constexpr float add_cast_round_down(float x, double y) {
54 #pragma STDC FENV_ROUND FE_DOWNWARD
55 float res = x;
56 res += y;
57 return res;
60 constexpr float add_cast_round_up(float x, double y) {
61 #pragma STDC FENV_ROUND FE_UPWARD
62 float res = x;
63 res += y;
64 return res;
67 float V3 = add_cast_round_down(1.0F, 0x0.000001p0F);
68 float V4 = add_cast_round_up(1.0F, 0x0.000001p0F);
70 // CHECK: @V3 = {{.*}} float 1.000000e+00
71 // CHECK: @V4 = {{.*}} float 0x3FF0000020000000