1214152Sed/* ===-- powidf2.cpp - Implement __powidf2 ---------------------------------=== 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 __powidf2 for the compiler_rt library. 11214152Sed * 12214152Sed * ===----------------------------------------------------------------------=== 13214152Sed */ 14214152Sed 15214152Sed#include "int_lib.h" 16214152Sed 17214152Sed/* Returns: a ^ b */ 18214152Sed 19222656SedCOMPILER_RT_ABI double 20214152Sed__powidf2(double a, si_int b) 21214152Sed{ 22214152Sed const int recip = b < 0; 23214152Sed double r = 1; 24214152Sed while (1) 25214152Sed { 26214152Sed if (b & 1) 27214152Sed r *= a; 28214152Sed b /= 2; 29214152Sed if (b == 0) 30214152Sed break; 31214152Sed a *= a; 32214152Sed } 33214152Sed return recip ? 1/r : r; 34214152Sed} 35