diff mbox

[4.8,14/26] Backport Power8 and LE support: DFP absolute value

Message ID 1395257555.17148.16.camel@gnopaine
State New
Headers show

Commit Message

Bill Schmidt March 19, 2014, 7:32 p.m. UTC
Hi,

This patch (diff-dfp-abs) backports some unrelated but necessary work to
enable the DFP absolute value builtins.  Copying Jakub who was involved
with the original patch.

Thanks,
Bill


2014-03-29  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	Backport from mainline
	2013-08-19  Peter Bergner  <bergner@vnet.ibm.com>
		    Jakub Jelinek  <jakub@redhat.com>

	* builtins.def (BUILT_IN_FABSD32): New DFP ABS builtin.
	(BUILT_IN_FABSD64): Likewise.
	(BUILT_IN_FABSD128): Likewise.
	* builtins.c (expand_builtin): Add support for
	new DFP ABS builtins.
	(fold_builtin_1): Likewise.
	* config/rs6000/dfp.md
	(*abstd2_fpr): Handle non-overlapping destination
	and source operands.
	(*nabstd2_fpr): Likewise.

2014-03-29  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	Backport from mainline
	2013-08-19  Peter Bergner  <bergner@vnet.ibm.com>

	* gcc.target/powerpc/dfp-dd-2.c: New test.
	* gcc.target/powerpc/dfp-td-2.c: Likewise.
	* gcc.target/powerpc/dfp-td-3.c: Likewise.

Comments

David Edelsohn April 3, 2014, 2:39 p.m. UTC | #1
On Wed, Mar 19, 2014 at 3:32 PM, Bill Schmidt
<wschmidt@linux.vnet.ibm.com> wrote:
> Hi,
>
> This patch (diff-dfp-abs) backports some unrelated but necessary work to
> enable the DFP absolute value builtins.  Copying Jakub who was involved
> with the original patch.
>
> Thanks,
> Bill
>
>
> 2014-03-29  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
>
>         Backport from mainline
>         2013-08-19  Peter Bergner  <bergner@vnet.ibm.com>
>                     Jakub Jelinek  <jakub@redhat.com>
>
>         * builtins.def (BUILT_IN_FABSD32): New DFP ABS builtin.
>         (BUILT_IN_FABSD64): Likewise.
>         (BUILT_IN_FABSD128): Likewise.
>         * builtins.c (expand_builtin): Add support for
>         new DFP ABS builtins.
>         (fold_builtin_1): Likewise.
>         * config/rs6000/dfp.md
>         (*abstd2_fpr): Handle non-overlapping destination
>         and source operands.
>         (*nabstd2_fpr): Likewise.
>
> 2014-03-29  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
>
>         Backport from mainline
>         2013-08-19  Peter Bergner  <bergner@vnet.ibm.com>
>
>         * gcc.target/powerpc/dfp-dd-2.c: New test.
>         * gcc.target/powerpc/dfp-td-2.c: Likewise.
>         * gcc.target/powerpc/dfp-td-3.c: Likewise.

Okay.

Thanks, David
diff mbox

Patch

Index: gcc-4_8-test/gcc/builtins.c
===================================================================
--- gcc-4_8-test.orig/gcc/builtins.c
+++ gcc-4_8-test/gcc/builtins.c
@@ -5861,6 +5861,9 @@  expand_builtin (tree exp, rtx target, rt
   switch (fcode)
     {
     CASE_FLT_FN (BUILT_IN_FABS):
+    case BUILT_IN_FABSD32:
+    case BUILT_IN_FABSD64:
+    case BUILT_IN_FABSD128:
       target = expand_builtin_fabs (exp, target, subtarget);
       if (target)
 	return target;
@@ -10313,6 +10316,9 @@  fold_builtin_1 (location_t loc, tree fnd
       return fold_builtin_strlen (loc, type, arg0);
 
     CASE_FLT_FN (BUILT_IN_FABS):
+    case BUILT_IN_FABSD32:
+    case BUILT_IN_FABSD64:
+    case BUILT_IN_FABSD128:
       return fold_builtin_fabs (loc, arg0, type);
 
     case BUILT_IN_ABS:
Index: gcc-4_8-test/gcc/builtins.def
===================================================================
--- gcc-4_8-test.orig/gcc/builtins.def
+++ gcc-4_8-test/gcc/builtins.def
@@ -252,6 +252,9 @@  DEF_C99_BUILTIN        (BUILT_IN_EXPM1L,
 DEF_LIB_BUILTIN        (BUILT_IN_FABS, "fabs", BT_FN_DOUBLE_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_C90RES_BUILTIN (BUILT_IN_FABSF, "fabsf", BT_FN_FLOAT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_C90RES_BUILTIN (BUILT_IN_FABSL, "fabsl", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
+DEF_GCC_BUILTIN        (BUILT_IN_FABSD32, "fabsd32", BT_FN_DFLOAT32_DFLOAT32, ATTR_CONST_NOTHROW_LEAF_LIST)
+DEF_GCC_BUILTIN        (BUILT_IN_FABSD64, "fabsd64", BT_FN_DFLOAT64_DFLOAT64, ATTR_CONST_NOTHROW_LEAF_LIST)
+DEF_GCC_BUILTIN        (BUILT_IN_FABSD128, "fabsd128", BT_FN_DFLOAT128_DFLOAT128, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_FDIM, "fdim", BT_FN_DOUBLE_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
 DEF_C99_BUILTIN        (BUILT_IN_FDIMF, "fdimf", BT_FN_FLOAT_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING_ERRNO)
 DEF_C99_BUILTIN        (BUILT_IN_FDIML, "fdiml", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
Index: gcc-4_8-test/gcc/config/rs6000/dfp.md
===================================================================
--- gcc-4_8-test.orig/gcc/config/rs6000/dfp.md
+++ gcc-4_8-test/gcc/config/rs6000/dfp.md
@@ -148,18 +148,24 @@ 
   "")
 
 (define_insn "*abstd2_fpr"
-  [(set (match_operand:TD 0 "gpc_reg_operand" "=d")
-	(abs:TD (match_operand:TD 1 "gpc_reg_operand" "d")))]
+  [(set (match_operand:TD 0 "gpc_reg_operand" "=d,d")
+	(abs:TD (match_operand:TD 1 "gpc_reg_operand" "0,d")))]
   "TARGET_HARD_FLOAT && TARGET_FPRS"
-  "fabs %0,%1"
-  [(set_attr "type" "fp")])
+  "@
+   fabs %0,%1
+   fabs %0,%1\;fmr %L0,%L1"
+  [(set_attr "type" "fp")
+   (set_attr "length" "4,8")])
 
 (define_insn "*nabstd2_fpr"
-  [(set (match_operand:TD 0 "gpc_reg_operand" "=d")
-	(neg:TD (abs:TD (match_operand:TD 1 "gpc_reg_operand" "d"))))]
+  [(set (match_operand:TD 0 "gpc_reg_operand" "=d,d")
+	(neg:TD (abs:TD (match_operand:TD 1 "gpc_reg_operand" "0,d"))))]
   "TARGET_HARD_FLOAT && TARGET_FPRS"
-  "fnabs %0,%1"
-  [(set_attr "type" "fp")])
+  "@
+   fnabs %0,%1
+   fnabs %0,%1\;fmr %L0,%L1"
+  [(set_attr "type" "fp")
+   (set_attr "length" "4,8")])
 
 ;; Hardware support for decimal floating point operations.
 
Index: gcc-4_8-test/gcc/testsuite/gcc.target/powerpc/dfp-dd-2.c
===================================================================
--- /dev/null
+++ gcc-4_8-test/gcc/testsuite/gcc.target/powerpc/dfp-dd-2.c
@@ -0,0 +1,26 @@ 
+/* Test generation of DFP instructions for POWER6.  */
+/* { dg-do compile { target { powerpc*-*-linux* && powerpc_fprs } } } */
+/* { dg-options "-std=gnu99 -O1 -mcpu=power6" } */
+
+/* { dg-final { scan-assembler-times "fneg" 1 } } */
+/* { dg-final { scan-assembler-times "fabs" 1 } } */
+/* { dg-final { scan-assembler-times "fnabs" 1 } } */
+/* { dg-final { scan-assembler-times "fmr" 0 } } */
+
+_Decimal64
+func1 (_Decimal64 a, _Decimal64 b)
+{
+  return -b;
+}
+
+_Decimal64
+func2 (_Decimal64 a, _Decimal64 b)
+{
+  return __builtin_fabsd64 (b);
+}
+
+_Decimal64
+func3 (_Decimal64 a, _Decimal64 b)
+{
+  return - __builtin_fabsd64 (b);
+}
Index: gcc-4_8-test/gcc/testsuite/gcc.target/powerpc/dfp-td-2.c
===================================================================
--- /dev/null
+++ gcc-4_8-test/gcc/testsuite/gcc.target/powerpc/dfp-td-2.c
@@ -0,0 +1,29 @@ 
+/* Test generation of DFP instructions for POWER6.  */
+/* { dg-do compile { target { powerpc*-*-linux* && powerpc_fprs } } } */
+/* { dg-options "-std=gnu99 -O1 -mcpu=power6" } */
+
+/* { dg-final { scan-assembler-times "fneg" 1 } } */
+/* { dg-final { scan-assembler-times "fabs" 1 } } */
+/* { dg-final { scan-assembler-times "fnabs" 1 } } */
+/* { dg-final { scan-assembler-times "fmr" 0 } } */
+
+/* These tests verify we only generate fneg, fabs and fnabs
+   instructions and no fmr's since these are done in place.  */
+
+_Decimal128
+func1 (_Decimal128 a)
+{
+  return -a;
+}
+
+_Decimal128
+func2 (_Decimal128 a)
+{
+  return __builtin_fabsd128 (a);
+}
+
+_Decimal128
+func3 (_Decimal128 a)
+{
+  return - __builtin_fabsd128 (a);
+}
Index: gcc-4_8-test/gcc/testsuite/gcc.target/powerpc/dfp-td-3.c
===================================================================
--- /dev/null
+++ gcc-4_8-test/gcc/testsuite/gcc.target/powerpc/dfp-td-3.c
@@ -0,0 +1,29 @@ 
+/* Test generation of DFP instructions for POWER6.  */
+/* { dg-do compile { target { powerpc*-*-linux* && powerpc_fprs } } } */
+/* { dg-options "-std=gnu99 -O1 -mcpu=power6" } */
+
+/* { dg-final { scan-assembler-times "fneg" 1 } } */
+/* { dg-final { scan-assembler-times "fabs" 1 } } */
+/* { dg-final { scan-assembler-times "fnabs" 1 } } */
+/* { dg-final { scan-assembler-times "fmr" 3 } } */
+
+/* These tests verify we generate fneg, fabs and fnabs and
+   associated fmr's since these are not done in place.  */
+
+_Decimal128
+func1 (_Decimal128 a, _Decimal128 b)
+{
+  return -b;
+}
+
+_Decimal128
+func2 (_Decimal128 a, _Decimal128 b)
+{
+  return __builtin_fabsd128 (b);
+}
+
+_Decimal128
+func3 (_Decimal128 a, _Decimal128 b)
+{
+  return - __builtin_fabsd128 (b);
+}