1//===-- powixf2.cpp - Implement __powixf2 ---------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements __powixf2 for the compiler_rt library.
10//
11//===----------------------------------------------------------------------===//
12
13#if !_ARCH_PPC
14
15#include "int_lib.h"
16
17// Returns: a ^ b
18
19COMPILER_RT_ABI xf_float __powixf2(xf_float a, int b) {
20 const int recip = b < 0;
21 xf_float r = 1;
22 while (1) {
23 if (b & 1)
24 r *= a;
25 b /= 2;
26 if (b == 0)
27 break;
28 a *= a;
29 }
30 return recip ? 1 / r : r;
31}
32
33#endif
34

source code of compiler-rt/lib/builtins/powixf2.c