Mercurial > hg > CbC > CbC_llvm
comparison clang/test/AST/const-fpfeatures.cpp @ 207:2e18cbf3894f
LLVM12
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 08 Jun 2021 06:07:14 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
173:0572611fdcc8 | 207:2e18cbf3894f |
---|---|
1 // RUN: %clang_cc1 -S -emit-llvm -triple i386-linux -std=c++2a -Wno-unknown-pragmas %s -o - | FileCheck %s | |
2 | |
3 // nextUp(1.F) == 0x1.000002p0F | |
4 | |
5 constexpr float add_round_down(float x, float y) { | |
6 #pragma STDC FENV_ROUND FE_DOWNWARD | |
7 float res = x; | |
8 res += y; | |
9 return res; | |
10 } | |
11 | |
12 constexpr float add_round_up(float x, float y) { | |
13 #pragma STDC FENV_ROUND FE_UPWARD | |
14 float res = x; | |
15 res += y; | |
16 return res; | |
17 } | |
18 | |
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 | |
23 | |
24 constexpr float add_cast_round_down(float x, double y) { | |
25 #pragma STDC FENV_ROUND FE_DOWNWARD | |
26 float res = x; | |
27 res += y; | |
28 return res; | |
29 } | |
30 | |
31 constexpr float add_cast_round_up(float x, double y) { | |
32 #pragma STDC FENV_ROUND FE_UPWARD | |
33 float res = x; | |
34 res += y; | |
35 return res; | |
36 } | |
37 | |
38 float V3 = add_cast_round_down(1.0F, 0x0.000001p0F); | |
39 float V4 = add_cast_round_up(1.0F, 0x0.000001p0F); | |
40 | |
41 // CHECK: @V3 = {{.*}} float 1.000000e+00 | |
42 // CHECK: @V4 = {{.*}} float 0x3FF0000020000000 | |
43 | |
44 // The next three variables use the same function as initializer, only rounding | |
45 // modes differ. | |
46 | |
47 float V5 = []() -> float { | |
48 return [](float x, float y)->float { | |
49 #pragma STDC FENV_ROUND FE_UPWARD | |
50 return x + y; | |
51 }([](float x, float y) -> float { | |
52 #pragma STDC FENV_ROUND FE_UPWARD | |
53 return x + y; | |
54 }(1.0F, 0x0.000001p0F), | |
55 0x0.000001p0F); | |
56 }(); | |
57 // CHECK: @V5 = {{.*}} float 0x3FF0000040000000 | |
58 | |
59 float V6 = []() -> float { | |
60 return [](float x, float y)->float { | |
61 #pragma STDC FENV_ROUND FE_DOWNWARD | |
62 return x + y; | |
63 }([](float x, float y) -> float { | |
64 #pragma STDC FENV_ROUND FE_UPWARD | |
65 return x + y; | |
66 }(1.0F, 0x0.000001p0F), | |
67 0x0.000001p0F); | |
68 }(); | |
69 // CHECK: @V6 = {{.*}} float 0x3FF0000020000000 | |
70 | |
71 float V7 = []() -> float { | |
72 return [](float x, float y)->float { | |
73 #pragma STDC FENV_ROUND FE_DOWNWARD | |
74 return x + y; | |
75 }([](float x, float y) -> float { | |
76 #pragma STDC FENV_ROUND FE_DOWNWARD | |
77 return x + y; | |
78 }(1.0F, 0x0.000001p0F), | |
79 0x0.000001p0F); | |
80 }(); | |
81 // CHECK: @V7 = {{.*}} float 1.000000e+00 |