Index: libgcc/config/rs6000/_powikf2.c
===================================================================
--- libgcc/config/rs6000/_powikf2.c	(revision 0)
+++ libgcc/config/rs6000/_powikf2.c	(revision 0)
@@ -0,0 +1,45 @@
+/* Copyright (C) 1989-2018 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+/* This is a temporary specialization of code from libgcc/libgcc2.c.  */
+
+#include "soft-fp.h"
+#include "quad-float128.h"
+
+#if defined(FLOAT128_HW_INSNS) && !defined(__powikf2)
+#define __powikf2 __powikf2_sw
+#endif
+
+TFtype
+__powikf2 (TFtype x, SItype_ppc m)
+{
+  unsigned int n = m < 0 ? -m : m;
+  TFtype y = n % 2 ? x : 1;
+  while (n >>= 1)
+    {
+      x = x * x;
+      if (n % 2)
+	y = y * x;
+    }
+  return m < 0 ? 1/y : y;
+}
Index: libgcc/config/rs6000/float128-ifunc.c
===================================================================
--- libgcc/config/rs6000/float128-ifunc.c	(revision 259476)
+++ libgcc/config/rs6000/float128-ifunc.c	(working copy)
@@ -84,6 +84,12 @@ __negkf2_resolve (void)
   return SW_OR_HW (__negkf2_sw, __negkf2_hw);
 }
 
+static __typeof__ (__powikf2_sw) *
+__powikf2_resolve (void)
+{
+  return SW_OR_HW (__powikf2_sw, __powikf2_hw);
+}
+
 static __typeof__ (__floatsikf_sw) *
 __floatsikf_resolve (void)
 {
@@ -243,6 +249,9 @@ TFtype __divkf3 (TFtype, TFtype)
 TFtype __negkf2 (TFtype)
   __attribute__ ((__ifunc__ ("__negkf2_resolve")));
 
+TFtype __powikf2 (TFtype, SItype_ppc)
+  __attribute__ ((__ifunc__ ("__powikf2_resolve")));
+
 CMPtype __eqkf2 (TFtype, TFtype)
   __attribute__ ((__ifunc__ ("__eqkf2_resolve")));
 
Index: libgcc/config/rs6000/quad-float128.h
===================================================================
--- libgcc/config/rs6000/quad-float128.h	(revision 259476)
+++ libgcc/config/rs6000/quad-float128.h	(working copy)
@@ -72,6 +72,7 @@ extern TFtype __subkf3_sw (TFtype, TFtyp
 extern TFtype __mulkf3_sw (TFtype, TFtype);
 extern TFtype __divkf3_sw (TFtype, TFtype);
 extern TFtype __negkf2_sw (TFtype);
+extern TFtype __powikf2_sw (TFtype, SItype_ppc);
 extern CMPtype __eqkf2_sw (TFtype, TFtype);
 extern CMPtype __gekf2_sw (TFtype, TFtype);
 extern CMPtype __lekf2_sw (TFtype, TFtype);
@@ -114,6 +115,7 @@ extern TFtype __subkf3_hw (TFtype, TFtyp
 extern TFtype __mulkf3_hw (TFtype, TFtype);
 extern TFtype __divkf3_hw (TFtype, TFtype);
 extern TFtype __negkf2_hw (TFtype);
+extern TFtype __powikf2_hw (TFtype, SItype_ppc);
 extern CMPtype __eqkf2_hw (TFtype, TFtype);
 extern CMPtype __gekf2_hw (TFtype, TFtype);
 extern CMPtype __lekf2_hw (TFtype, TFtype);
@@ -142,6 +144,7 @@ extern TFtype __subkf3 (TFtype, TFtype);
 extern TFtype __mulkf3 (TFtype, TFtype);
 extern TFtype __divkf3 (TFtype, TFtype);
 extern TFtype __negkf2 (TFtype);
+extern TFtype __powikf2 (TFtype, SItype_ppc);
 extern CMPtype __eqkf2 (TFtype, TFtype);
 extern CMPtype __nekf2 (TFtype, TFtype);
 extern CMPtype __gekf2 (TFtype, TFtype);
Index: libgcc/config/rs6000/t-float128
===================================================================
--- libgcc/config/rs6000/t-float128	(revision 259476)
+++ libgcc/config/rs6000/t-float128	(working copy)
@@ -25,7 +25,7 @@ fp128_softfp_obj	= $(fp128_softfp_static
 # New functions for software emulation
 fp128_ppc_funcs		= floattikf floatuntikf fixkfti fixunskfti \
 			  extendkftf2-sw trunctfkf2-sw \
-			  sfp-exceptions _mulkc3 _divkc3
+			  sfp-exceptions _mulkc3 _divkc3 _powikf2
 
 fp128_ppc_src		= $(addprefix $(srcdir)/config/rs6000/,$(addsuffix \
 				.c,$(fp128_ppc_funcs)))
Index: libgcc/config/rs6000/t-float128-hw
===================================================================
--- libgcc/config/rs6000/t-float128-hw	(revision 259476)
+++ libgcc/config/rs6000/t-float128-hw	(working copy)
@@ -6,9 +6,9 @@ FLOAT128_HW_INSNS	= -DFLOAT128_HW_INSNS
 
 # New functions for hardware support
 fp128_hardfp_src	= _mulkc3-hw.c _divkc3-hw.c
-fp128_hw_funcs		= float128-hw _mulkc3-hw _divkc3-hw
+fp128_hw_funcs		= float128-hw _mulkc3-hw _divkc3-hw _powikf2-hw
 fp128_hw_src		= $(srcdir)/config/rs6000/float128-hw.c _mulkc3-hw.c \
-			  _divkc3-hw.c
+			  _divkc3-hw.c _powikf2-hw.c
 fp128_hw_static_obj	= $(addsuffix $(objext),$(fp128_hw_funcs))
 fp128_hw_shared_obj	= $(addsuffix _s$(objext),$(fp128_hw_funcs))
 fp128_hw_obj		= $(fp128_hw_static_obj) $(fp128_hw_shared_obj)
@@ -43,3 +43,7 @@ _mulkc3-hw.c: $(srcdir)/config/rs6000/_m
 _divkc3-hw.c: $(srcdir)/config/rs6000/_divkc3.c
 	(echo "#define __divkc3 __divkc3_hw"; \
 	 cat $(srcdir)/config/rs6000/_divkc3.c) > _divkc3-hw.c
+
+_powikf2-hw.c: $(srcdir)/config/rs6000/_powikf2.c
+	(echo "#define __powikf2 __powikf2_hw"; \
+	 cat $(srcdir)/config/rs6000/_powikf2.c) > _powikf2-hw.c
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(revision 259476)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -18644,6 +18644,7 @@ init_float128_ieee (machine_mode mode)
       set_optab_libfunc (sdiv_optab, mode, "__divkf3");
       set_optab_libfunc (sqrt_optab, mode, "__sqrtkf2");
       set_optab_libfunc (abs_optab, mode, "__abstkf2");
+      set_optab_libfunc (powi_optab, mode, "__powitkf2");
 
       set_optab_libfunc (eq_optab, mode, "__eqkf2");
       set_optab_libfunc (ne_optab, mode, "__nekf2");
Index: gcc/testsuite/gcc.target/powerpc/pr85456.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr85456.c	(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr85456.c	(revision 0)
@@ -0,0 +1,14 @@
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-require-effective-target powerpc_p8vector_ok } */
+/* { dg-options "-O2 -mpower8-vector -mabi=ieeelongdouble -Wno-psabi" } */
+
+/* Check that the __builtin_powil generates a call to the correct function
+   when long double uses IEEE 128-bit floating point.  */
+
+long double
+do_powl (long double a, int i)
+{
+  return __builtin_powil (a, i);
+}
+
+/* { dg-final { scan-assembler "bl __powikf2" } } */
