blob: 4b14c81b322f5c035fa5360259726aedb7f7e81a [file] [log] [blame]
Eli Friedmand674d962019-03-19 21:55:58 +00001// RUN: %clang_builtins %s %librt -o %t && %run %t
2//===--------------- divsf3_test.c - Test __divsf3 ------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9//
10// This file tests __divsf3 for the compiler_rt library.
11//
12//===----------------------------------------------------------------------===//
13
14#include "int_lib.h"
15#include <stdio.h>
16
17#include "fp_test.h"
18
19// Returns: a / b
20COMPILER_RT_ABI float __divsf3(float a, float b);
21
22int test__divsf3(float a, float b, uint32_t expected)
23{
24 float x = __divsf3(a, b);
25 int ret = compareResultF(x, expected);
26
27 if (ret){
28 printf("error in test__divsf3(%.20e, %.20e) = %.20e, "
29 "expected %.20e\n", a, b, x,
30 fromRep32(expected));
31 }
32 return ret;
33}
34
35int main()
36{
37 // 1/3
38 if (test__divsf3(1.f, 3.f, 0x3EAAAAABU))
39 return 1;
40 // smallest normal result
41 if (test__divsf3(2.3509887e-38, 2., 0x00800000U))
42 return 1;
43
44 return 0;
45}