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