Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / lib / builtins / powitf2.c
blobe02db40767ac03d397b943ca87d606c5e7e20311
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.
11 //===----------------------------------------------------------------------===//
13 #define QUAD_PRECISION
14 #include "fp_lib.h"
16 #if defined(CRT_HAS_TF_MODE)
18 // Returns: a ^ b
20 COMPILER_RT_ABI fp_t __powitf2(fp_t a, int b) {
21 const int recip = b < 0;
22 fp_t r = 1;
23 while (1) {
24 if (b & 1)
25 r *= a;
26 b /= 2;
27 if (b == 0)
28 break;
29 a *= a;
31 return recip ? 1 / r : r;
34 #endif