llvm-project/libclc/clc/lib/generic/conversion/clc_convert_integer.cl
Wenju He ae67b88c0a
[libclc] Compile clc_convert_float2int.cl and clc_convert_int2float.cl separately (#173454)
776f5933c9d4 merged into clc_convert_integer.cl to avoid many
regressions, e.g. in function _Z17convert_float_rtnc:
  in block %1 / %1:
    >   ret float %2
    <   %.inv.i.i = fcmp ole float %2, -1.280000e+02
    <   %3 = select i1 %.inv.i.i, float -1.280000e+02, float %2
    <   %4 = fptosi float %3 to i8
    <   %.not.i = icmp eq i8 %0, 127
    <   %5 = icmp sge i8 %0, %4
    <   %.not2.i = select i1 %.not.i, i1 true, i1 %5
    <   %6 = bitcast float %2 to i32
    <   %7 = sub nsw i32 -2147483648, %6
    <   %8 = icmp slt i8 %0, 0
    <   %9 = select i1 %8, i32 %7, i32 %6
    <   %10 = icmp sgt i32 %9, -2139095041
    <   %11 = select i1 %10, i32 -1, i32 1
    <   %12 = add nsw i32 %11, %9
    <   %13 = sub i32 -2147483648, %12
    <   %14 = icmp slt i32 %12, 0
    <   %15 = icmp ne i32 %12, 0
    <   %16 = or i1 %10, %15
    <   %17 = select i1 %16, i32 %12, i32 -2147483648
    <   %18 = select i1 %14, i32 %13, i32 %17
    <   %19 = icmp eq i32 %6, -8388608
    <   %20 = bitcast i32 %18 to float
    <   %21 = select i1 %19, float 0xFFF0000000000000, float %20
    <   %22 = select i1 %.not2.i, float %2, float %21
    <   ret float %22
This regression is fixed by 993054d96fdf.
2026-01-06 09:18:54 +08:00

62 lines
2.1 KiB
Common Lisp

//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
#include <clc/clc_convert.h>
#include <clc/integer/definitions.h>
#include <clc/shared/clc_clamp.h>
#include <clc/shared/clc_max.h>
#include <clc/shared/clc_min.h>
#define __CLC_S_SCALAR_TYPE_SRC __CLC_SCALAR_TYPE_SRC
#define __CLC_U_SCALAR_TYPE_SRC __CLC_XCONCAT(u, __CLC_SCALAR_TYPE_SRC)
#define __CLC_S_GENTYPE_SRC \
__CLC_XCONCAT(__CLC_S_SCALAR_TYPE_SRC, __CLC_VECSIZE)
#define __CLC_U_GENTYPE_SRC \
__CLC_XCONCAT(__CLC_U_SCALAR_TYPE_SRC, __CLC_VECSIZE)
#define __CLC_FUNCTION __CLC_XCONCAT(__clc_convert_, __CLC_GENTYPE)
#define __CLC_FUNCTION_SAT __CLC_XCONCAT(__CLC_FUNCTION, _sat)
#define __CLC_SCALAR_TYPE_SRC char
#define __CLC_GENSIZE_SRC 8
#define __CLC_BODY <clc_convert_integer.inc>
#include <clc/integer/gentype.inc>
#undef __CLC_SCALAR_TYPE_SRC
#undef __CLC_GENSIZE_SRC
#define __CLC_SCALAR_TYPE_SRC short
#define __CLC_GENSIZE_SRC 16
#define __CLC_BODY <clc_convert_integer.inc>
#include <clc/integer/gentype.inc>
#undef __CLC_SCALAR_TYPE_SRC
#undef __CLC_GENSIZE_SRC
#define __CLC_SCALAR_TYPE_SRC int
#define __CLC_GENSIZE_SRC 32
#define __CLC_BODY <clc_convert_integer.inc>
#include <clc/integer/gentype.inc>
#undef __CLC_SCALAR_TYPE_SRC
#undef __CLC_GENSIZE_SRC
#if defined cles_khr_int64 || !defined(__EMBEDDED_PROFILE__)
#define __CLC_SCALAR_TYPE_SRC long
#define __CLC_GENSIZE_SRC 64
#define __CLC_BODY <clc_convert_integer.inc>
#include <clc/integer/gentype.inc>
#undef __CLC_SCALAR_TYPE_SRC
#undef __CLC_GENSIZE_SRC
#endif // defined cles_khr_int64 || !defined(__EMBEDDED_PROFILE__)
#undef __CLC_S_SCALAR_TYPE_SRC
#undef __CLC_U_SCALAR_TYPE_SRC
#undef __CLC_S_GENTYPE_SRC
#undef __CLC_U_GENTYPE_SRC
#undef __CLC_FUNCTION
#undef __CLC_FUNCTION_SAT