1214152Sed/* ===-- powixf2.cpp - Implement __powixf2 ---------------------------------=== 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 __powixf2 for the compiler_rt library. 11214152Sed * 12214152Sed * ===----------------------------------------------------------------------=== 13214152Sed */ 14214152Sed 15214152Sed#if !_ARCH_PPC 16214152Sed 17214152Sed#include "int_lib.h" 18214152Sed 19214152Sed/* Returns: a ^ b */ 20214152Sed 21214152Sedlong double 22214152Sed__powixf2(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