Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / lib / builtins / powidf2.c
blob81058af508297a502740e4c06f15635dd24828c5
1 //===-- powidf2.cpp - Implement __powidf2 ---------------------------------===//
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 __powidf2 for the compiler_rt library.
11 //===----------------------------------------------------------------------===//
13 #include "int_lib.h"
15 // Returns: a ^ b
17 COMPILER_RT_ABI double __powidf2(double a, int b) {
18 const int recip = b < 0;
19 double r = 1;
20 while (1) {
21 if (b & 1)
22 r *= a;
23 b /= 2;
24 if (b == 0)
25 break;
26 a *= a;
28 return recip ? 1 / r : r;