CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
86 lines
3.0 KiB
C
86 lines
3.0 KiB
C
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
// RUN: %clang_builtins %s %librt -o %t && %run %t
|
|
// REQUIRES: librt_has_fixunssfsi
|
|
|
|
#include "int_lib.h"
|
|
#include <inttypes.h>
|
|
#include <stdio.h>
|
|
|
|
#include "fp_test.h"
|
|
|
|
// By default this test does not specify the expected results for overflowing
|
|
// and NaN inputs, because they can vary between platforms. For the Arm
|
|
// optimized FP implementation, which commits to more detail, we include some
|
|
// extra test cases specific to that NaN policy.
|
|
#if COMPILER_RT_ARM_OPTIMIZED_FP
|
|
# define ARM_INVALID_HANDLING
|
|
#endif
|
|
|
|
// Returns: a converted from float to uint32_t
|
|
COMPILER_RT_ABI uint32_t __fixunssfsi(float a);
|
|
|
|
int test__fixunssfsi(uint32_t a_rep, uint32_t expected, int line) {
|
|
float a = fromRep32(a_rep);
|
|
int32_t x = __fixunssfsi(a);
|
|
int ret = x != expected;
|
|
|
|
if (ret) {
|
|
printf("error at line %d: __fixunssfsi(%08" PRIx32 ") = %08" PRIx32
|
|
", expected %08" PRIx32 "\n",
|
|
line, a_rep, x, expected);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
#define test__fixunssfsi(a, x) test__fixunssfsi(a, x, __LINE__)
|
|
|
|
int main(void) {
|
|
int status = 0;
|
|
|
|
status |= test__fixunssfsi(0x00000000, 0x00000000);
|
|
status |= test__fixunssfsi(0x00000001, 0x00000000);
|
|
status |= test__fixunssfsi(0x00000001, 0x00000000);
|
|
status |= test__fixunssfsi(0x00500000, 0x00000000);
|
|
status |= test__fixunssfsi(0x00500000, 0x00000000);
|
|
status |= test__fixunssfsi(0x3e800000, 0x00000000);
|
|
status |= test__fixunssfsi(0x3f000000, 0x00000000);
|
|
status |= test__fixunssfsi(0x3f400000, 0x00000000);
|
|
status |= test__fixunssfsi(0x3f800000, 0x00000001);
|
|
status |= test__fixunssfsi(0x3fa00000, 0x00000001);
|
|
status |= test__fixunssfsi(0x3fc00000, 0x00000001);
|
|
status |= test__fixunssfsi(0x3fe00000, 0x00000001);
|
|
status |= test__fixunssfsi(0x40000000, 0x00000002);
|
|
status |= test__fixunssfsi(0x40100000, 0x00000002);
|
|
status |= test__fixunssfsi(0x40200000, 0x00000002);
|
|
status |= test__fixunssfsi(0x40300000, 0x00000002);
|
|
status |= test__fixunssfsi(0x4f7fffff, 0xffffff00);
|
|
status |= test__fixunssfsi(0x80000000, 0x00000000);
|
|
status |= test__fixunssfsi(0xbf7fffff, 0x00000000);
|
|
|
|
#ifdef ARM_INVALID_HANDLING
|
|
// Tests specific to the handling of float-to-integer conversions in
|
|
// Arm hardware, mimicked by arm/fixunssfsi.S:
|
|
//
|
|
// - too-large positive inputs, including +infinity, return the
|
|
// maximum possible unsigned integer value
|
|
//
|
|
// - negative inputs too small to round up to 0, including
|
|
// -infinity, return 0
|
|
//
|
|
// - NaN inputs return 0
|
|
status |= test__fixunssfsi(0x4f800000, 0xffffffff);
|
|
status |= test__fixunssfsi(0x7f800000, 0xffffffff);
|
|
status |= test__fixunssfsi(0x7fa111d3, 0x00000000);
|
|
status |= test__fixunssfsi(0x7febfdda, 0x00000000);
|
|
status |= test__fixunssfsi(0xbf800000, 0x00000000);
|
|
status |= test__fixunssfsi(0xc0000000, 0x00000000);
|
|
status |= test__fixunssfsi(0xff800000, 0x00000000);
|
|
|
|
#endif // ARM_INVALID_HANDLING
|
|
|
|
return status;
|
|
}
|