From 2f172d8d3c10ea7538818cbfffeb54ef30bb1a11 Mon Sep 17 00:00:00 2001
From: Sam Clegg <sbc@chromium.org>
Date: Fri, 7 Feb 2020 18:15:15 -0800
Subject: [PATCH] [compiler-rt] Compile __powitf2 under wasm

See https://github.com/emscripten-core/emscripten/issues/10374
See https://reviews.llvm.org/D74274

Differential Revision: https://reviews.llvm.org/D74275
---
 compiler-rt/lib/builtins/powitf2.c            | 5 +++--
 compiler-rt/test/builtins/Unit/powitf2_test.c | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/compiler-rt/lib/builtins/powitf2.c b/compiler-rt/lib/builtins/powitf2.c
index fcbdb4c2ee2a..141a3a0ea727 100644
--- a/compiler-rt/lib/builtins/powitf2.c
+++ b/compiler-rt/lib/builtins/powitf2.c
@@ -10,9 +10,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "int_lib.h"
+#define QUAD_PRECISION
+#include "fp_lib.h"
 
-#if _ARCH_PPC
+#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
 
 // Returns: a ^ b
 
diff --git a/compiler-rt/test/builtins/Unit/powitf2_test.c b/compiler-rt/test/builtins/Unit/powitf2_test.c
index 70bc6dae0d2d..fd25f38d5177 100644
--- a/compiler-rt/test/builtins/Unit/powitf2_test.c
+++ b/compiler-rt/test/builtins/Unit/powitf2_test.c
@@ -14,7 +14,7 @@
 
 #include <stdio.h>
 
-#if _ARCH_PPC
+#if __LDBL_MANT_DIG__ == 113
 
 #include "int_lib.h"
 #include <math.h>
@@ -37,7 +37,7 @@ int test__powitf2(long double a, si_int b, long double expected)
 
 int main()
 {
-#if _ARCH_PPC
+#if __LDBL_MANT_DIG__ == 113
     if (test__powitf2(0, 0, 1))
         return 1;
     if (test__powitf2(1, 0, 1))