|
| 1 | +// RUN: %clang_cc1 -emit-llvm -triple i386-linux -Wno-unknown-pragmas %s -o - | FileCheck %s |
| 2 | + |
| 3 | +double sin(double); |
| 4 | +double sin_rte(double); |
| 5 | +double sin_rtz(double); |
| 6 | +double sin_rtp(double); |
| 7 | +double sin_rtn(double); |
| 8 | +double sin_rta(double); |
| 9 | + |
| 10 | +#define CONCAT(a, b) CONCAT_(a, b) |
| 11 | +#define CONCAT_(a, b) a##b |
| 12 | +#define ADD_ROUNDING_MODE_SUFFIX(func) CONCAT(func, __ROUNDING_MODE__) |
| 13 | + |
| 14 | +#define sin(x) ADD_ROUNDING_MODE_SUFFIX(sin)(x) |
| 15 | + |
| 16 | +double call_dyn(double x) { |
| 17 | + return sin(x); |
| 18 | +} |
| 19 | +// CHECK-LABEL: define {{.*}} double @call_dyn( |
| 20 | +// CHECK: call double @sin( |
| 21 | + |
| 22 | +#pragma STDC FENV_ROUND FE_TOWARDZERO |
| 23 | +double call_tz(double x) { |
| 24 | + return sin(x); |
| 25 | +} |
| 26 | +// CHECK-LABEL: define {{.*}} double @call_tz( |
| 27 | +// CHECK: call double @sin_rtz( |
| 28 | + |
| 29 | +#pragma STDC FENV_ROUND FE_TONEAREST |
| 30 | +double call_te(double x) { |
| 31 | + return sin(x); |
| 32 | +} |
| 33 | +// CHECK-LABEL: define {{.*}} double @call_te( |
| 34 | +// CHECK: call double @sin_rte( |
| 35 | + |
| 36 | +#pragma STDC FENV_ROUND FE_DOWNWARD |
| 37 | +double call_tn(double x) { |
| 38 | + return sin(x); |
| 39 | +} |
| 40 | +// CHECK-LABEL: define {{.*}} double @call_tn( |
| 41 | +// CHECK: call double @sin_rtn( |
| 42 | + |
| 43 | +#pragma STDC FENV_ROUND FE_UPWARD |
| 44 | +double call_tp(double x) { |
| 45 | + return sin(x); |
| 46 | +} |
| 47 | +// CHECK-LABEL: define {{.*}} double @call_tp( |
| 48 | +// CHECK: call double @sin_rtp( |
| 49 | + |
| 50 | +#pragma STDC FENV_ROUND FE_TONEARESTFROMZERO |
| 51 | +double call_tea(double x) { |
| 52 | + return sin(x); |
| 53 | +} |
| 54 | +// CHECK-LABEL: define {{.*}} double @call_tea( |
| 55 | +// CHECK: call double @sin_rta( |
0 commit comments