1214152Sed/* ===-- powitf2.cpp - Implement __powitf2 ---------------------------------=== 2214152Sed * 3214152Sed * The LLVM Compiler Infrastructure 4214152Sed * 5222656Sed * This file is dual licensed under the MIT and the University of Illinois Open 6222656Sed * Source Licenses. See LICENSE.TXT for details. 7214152Sed * 8214152Sed * ===----------------------------------------------------------------------=== 9214152Sed * 10214152Sed * This file implements __powitf2 for the compiler_rt library. 11214152Sed * 12214152Sed * ===----------------------------------------------------------------------=== 13214152Sed */ 14214152Sed 15263560Sdim#include "int_lib.h" 16263560Sdim 17214152Sed#if _ARCH_PPC 18214152Sed 19214152Sed/* Returns: a ^ b */ 20214152Sed 21214152Sedlong double 22214152Sed__powitf2(long double a, si_int b) 23214152Sed{ 24214152Sed const int recip = b < 0; 25214152Sed long double r = 1; 26214152Sed while (1) 27214152Sed { 28214152Sed if (b & 1) 29214152Sed r *= a; 30214152Sed b /= 2; 31214152Sed if (b == 0) 32214152Sed break; 33214152Sed a *= a; 34214152Sed } 35214152Sed return recip ? 1/r : r; 36214152Sed} 37214152Sed 38214152Sed#endif 39