brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 5c44fd3 Raw
66 lines · cpp
1// RUN: %clang_cc1 -emit-llvm -triple i386-linux -Wno-unknown-pragmas -frounding-math %s -o - | FileCheck %s2 3constexpr float func_01(float x, float y) {4  return x + y;5}6 7float V1 = func_01(1.0F, 0x0.000001p0F);8float V2 = 1.0F + 0x0.000001p0F;9float V3 = func_01(1.0F, 2.0F);10 11// CHECK: @V1 = {{.*}}global float 1.000000e+00, align 412// CHECK: @V2 = {{.*}}global float 1.000000e+00, align 413// CHECK: @V3 = {{.*}}global float 3.000000e+00, align 414 15void test_builtin_elementwise_fma_round_upward() {16  #pragma STDC FENV_ACCESS ON17  #pragma STDC FENV_ROUND FE_UPWARD18 19  // CHECK: store float 0x4018000100000000, ptr %f120  // CHECK: store float 0x4018000100000000, ptr %f221  constexpr float f1 = __builtin_elementwise_fma(2.0F, 3.000001F, 0.000001F);22  constexpr float f2 = 2.0F * 3.000001F + 0.000001F;23  static_assert(f1 == f2);24  static_assert(f1 == 6.00000381F);25  // CHECK: store double 0x40180000C9539B89, ptr %d126  // CHECK: store double 0x40180000C9539B89, ptr %d227  constexpr double d1 = __builtin_elementwise_fma(2.0, 3.000001, 0.000001);28  constexpr double d2 = 2.0 * 3.000001 + 0.000001;29  static_assert(d1 == d2);30  static_assert(d1 == 6.0000030000000004);31}32 33void test_builtin_elementwise_fma_round_downward() {34  #pragma STDC FENV_ACCESS ON35  #pragma STDC FENV_ROUND FE_DOWNWARD36 37  // CHECK: store float 0x40180000C0000000, ptr %f338  // CHECK: store float 0x40180000C0000000, ptr %f439  constexpr float f3 = __builtin_elementwise_fma(2.0F, 3.000001F, 0.000001F);40  constexpr float f4 = 2.0F * 3.000001F + 0.000001F;41  static_assert(f3 == f4);42  // CHECK: store double 0x40180000C9539B87, ptr %d343  // CHECK: store double 0x40180000C9539B87, ptr %d444  constexpr double d3 = __builtin_elementwise_fma(2.0, 3.000001, 0.000001);45  constexpr double d4 = 2.0 * 3.000001 + 0.000001;46  static_assert(d3 == d4);47}48 49void test_builtin_elementwise_fma_round_nearest() {50  #pragma STDC FENV_ACCESS ON51  #pragma STDC FENV_ROUND FE_TONEAREST52 53  // CHECK: store float 0x40180000C0000000, ptr %f554  // CHECK: store float 0x40180000C0000000, ptr %f655  constexpr float f5 = __builtin_elementwise_fma(2.0F, 3.000001F, 0.000001F);56  constexpr float f6 = 2.0F * 3.000001F + 0.000001F;57  static_assert(f5 == f6);58  static_assert(f5 == 6.00000286F);59  // CHECK: store double 0x40180000C9539B89, ptr %d560  // CHECK: store double 0x40180000C9539B89, ptr %d661  constexpr double d5 = __builtin_elementwise_fma(2.0, 3.000001, 0.000001);62  constexpr double d6 = 2.0 * 3.000001 + 0.000001;63  static_assert(d5 == d6);64  static_assert(d5 == 6.0000030000000004);65}66