1 //===-- powitf2.cpp - Implement __powitf2 ---------------------------------===// 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 __powitf2 for the compiler_rt library. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #include "int_lib.h" 14 15 #if _ARCH_PPC 16 17 // Returns: a ^ b 18 19 COMPILER_RT_ABI long double __powitf2(long double a, si_int b) { 20 const int recip = b < 0; 21 long double 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