mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 03:16:07 +00:00

Use of long double can be error-prone since it could be one of 80-bit extended precision float, IEEE 128-bit float, or IBM 128-bit float. Instead use an explicit xf_float typedef for the remaining cases where long double is being used in the implementation. This patch does not touch the PPC specializations which still use long double.
34 lines
816 B
C
34 lines
816 B
C
//===-- powixf2.cpp - Implement __powixf2 ---------------------------------===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file implements __powixf2 for the compiler_rt library.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#if !_ARCH_PPC
|
|
|
|
#include "int_lib.h"
|
|
|
|
// Returns: a ^ b
|
|
|
|
COMPILER_RT_ABI xf_float __powixf2(xf_float a, int b) {
|
|
const int recip = b < 0;
|
|
xf_float r = 1;
|
|
while (1) {
|
|
if (b & 1)
|
|
r *= a;
|
|
b /= 2;
|
|
if (b == 0)
|
|
break;
|
|
a *= a;
|
|
}
|
|
return recip ? 1 / r : r;
|
|
}
|
|
|
|
#endif
|