Path: blob/main/core/posix-wasm/src/lib/builtins/mulsc3.c
1067 views
//===-- mulsc3.c - Implement __mulsc3 -------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file implements __mulsc3 for the compiler_rt library.9//10//===----------------------------------------------------------------------===//1112#include "int_lib.h"13#include "int_math.h"1415// Returns: the product of a + ib and c + id1617COMPILER_RT_ABI Fcomplex __mulsc3(float __a, float __b, float __c, float __d) {18float __ac = __a * __c;19float __bd = __b * __d;20float __ad = __a * __d;21float __bc = __b * __c;22Fcomplex z;23COMPLEX_REAL(z) = __ac - __bd;24COMPLEX_IMAGINARY(z) = __ad + __bc;25if (crt_isnan(COMPLEX_REAL(z)) && crt_isnan(COMPLEX_IMAGINARY(z))) {26int __recalc = 0;27if (crt_isinf(__a) || crt_isinf(__b)) {28__a = crt_copysignf(crt_isinf(__a) ? 1 : 0, __a);29__b = crt_copysignf(crt_isinf(__b) ? 1 : 0, __b);30if (crt_isnan(__c))31__c = crt_copysignf(0, __c);32if (crt_isnan(__d))33__d = crt_copysignf(0, __d);34__recalc = 1;35}36if (crt_isinf(__c) || crt_isinf(__d)) {37__c = crt_copysignf(crt_isinf(__c) ? 1 : 0, __c);38__d = crt_copysignf(crt_isinf(__d) ? 1 : 0, __d);39if (crt_isnan(__a))40__a = crt_copysignf(0, __a);41if (crt_isnan(__b))42__b = crt_copysignf(0, __b);43__recalc = 1;44}45if (!__recalc && (crt_isinf(__ac) || crt_isinf(__bd) || crt_isinf(__ad) ||46crt_isinf(__bc))) {47if (crt_isnan(__a))48__a = crt_copysignf(0, __a);49if (crt_isnan(__b))50__b = crt_copysignf(0, __b);51if (crt_isnan(__c))52__c = crt_copysignf(0, __c);53if (crt_isnan(__d))54__d = crt_copysignf(0, __d);55__recalc = 1;56}57if (__recalc) {58COMPLEX_REAL(z) = CRT_INFINITY * (__a * __c - __b * __d);59COMPLEX_IMAGINARY(z) = CRT_INFINITY * (__a * __d + __b * __c);60}61}62return z;63}646566