public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/meissner/heads/work055)] Add IEEE 128-bit min/max support on PowerPC.
@ 2021-06-08  0:31 Michael Meissner
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Meissner @ 2021-06-08  0:31 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:bad75ea8f8b0406041b270ff95f975f3baa8c546

commit bad75ea8f8b0406041b270ff95f975f3baa8c546
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Mon Jun 7 20:30:32 2021 -0400

    Add IEEE 128-bit min/max support on PowerPC.
    
    This patch adds the support for the IEEE 128-bit floating point C minimum and
    maximum instructions.  The next patch will add the support for using the
    compare and set mask instruction to implement conditional moves.
    
    This patch does not try to re-use the code used for SF/DF min/max
    support.  It defines a separate insn for the IEEE 128-bit support.  It
    uses the code iterator <minmax> to simplify adding both operations.
    
    GCC will not convert ternary operations into using min/max instructions
    provided in this patch unless the user uses -Ofast or similar switches due to
    issues with NaNs.  The next patch that adds conditional move instructions will
    enable the ternary conversion in many cases.
    
    gcc/
    2021-06-07  Michael Meissner  <meissner@linux.ibm.com>
    
            * config/rs6000/rs6000.c (rs6000_emit_minmax): Add support for ISA
            3.1 IEEE 128-bit floating point xsmaxcqp and xsmincqp instructions.
            * config/rs6000/rs6000.md (s<minmax><mode>3, IEEE128 iterator):
            New insns.
    
    gcc/testsuite/
    2021-06-07  Michael Meissner  <meissner@linux.ibm.com>
    
            * gcc.target/powerpc/float128-minmax-2.c: New test.
            * gcc.target/powerpc/float128-minmax.c: Do not run on power10.

Diff:
---
 gcc/config/rs6000/rs6000.c                           |  3 ++-
 gcc/config/rs6000/rs6000.md                          | 11 +++++++++++
 gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c | 15 +++++++++++++++
 gcc/testsuite/gcc.target/powerpc/float128-minmax.c   |  6 ++++--
 4 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index b01bb5c8191..1651788df6a 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -16103,7 +16103,8 @@ rs6000_emit_minmax (rtx dest, enum rtx_code code, rtx op0, rtx op1)
   /* VSX/altivec have direct min/max insns.  */
   if ((code == SMAX || code == SMIN)
       && (VECTOR_UNIT_ALTIVEC_OR_VSX_P (mode)
-	  || (mode == SFmode && VECTOR_UNIT_VSX_P (DFmode))))
+	  || (mode == SFmode && VECTOR_UNIT_VSX_P (DFmode))
+	  || (TARGET_POWER10 && TARGET_FLOAT128_HW && FLOAT128_IEEE_P (mode))))
     {
       emit_insn (gen_rtx_SET (dest, gen_rtx_fmt_ee (code, mode, op0, op1)));
       return;
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 3f59b544f6a..064c3a2d9d6 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -5214,6 +5214,17 @@
 }
   [(set_attr "type" "fp")])
 
+;; Min/max for ISA 3.1 IEEE 128-bit floating point
+(define_insn "s<minmax><mode>3"
+  [(set (match_operand:IEEE128 0 "altivec_register_operand" "=v")
+	(fp_minmax:IEEE128
+	 (match_operand:IEEE128 1 "altivec_register_operand" "v")
+	 (match_operand:IEEE128 2 "altivec_register_operand" "v")))]
+  "TARGET_POWER10"
+  "xs<minmax>cqp %0,%1,%2"
+  [(set_attr "type" "vecfloat")
+   (set_attr "size" "128")])
+
 ;; The conditional move instructions allow us to perform max and min operations
 ;; even when we don't have the appropriate max/min instruction using the FSEL
 ;; instruction.
diff --git a/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c b/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c
new file mode 100644
index 00000000000..c71ba08c9f8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c
@@ -0,0 +1,15 @@
+/* { dg-require-effective-target ppc_float128_hw } */
+/* { dg-require-effective-target power10_ok } */
+/* { dg-options "-mdejagnu-cpu=power10 -O2 -ffast-math" } */
+
+#ifndef TYPE
+#define TYPE _Float128
+#endif
+
+/* Test that the fminf128/fmaxf128 functions generate if/then/else and not a
+   call.  */
+TYPE f128_min (TYPE a, TYPE b) { return __builtin_fminf128 (a, b); }
+TYPE f128_max (TYPE a, TYPE b) { return __builtin_fmaxf128 (a, b); }
+
+/* { dg-final { scan-assembler {\mxsmaxcqp\M} } } */
+/* { dg-final { scan-assembler {\mxsmincqp\M} } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/float128-minmax.c b/gcc/testsuite/gcc.target/powerpc/float128-minmax.c
index fe397518f2f..d7bc60af9d8 100644
--- a/gcc/testsuite/gcc.target/powerpc/float128-minmax.c
+++ b/gcc/testsuite/gcc.target/powerpc/float128-minmax.c
@@ -1,8 +1,10 @@
 /* { dg-do compile { target lp64 } } */
-/* { dg-require-effective-target powerpc_p9vector_ok } */
+/* { dg-require-effective-target powerpc_p9vector_ok && ! power10_hw } */
 /* { dg-require-effective-target float128 } */
-/* { dg-options "-mpower9-vector -O2 -ffast-math" } */
+/* { dg-options "-O2 -ffast-math" } */
 
+/* We don't run this test on power10 because power10 has instructions to
+   implement min/max directly.  */
 #ifndef TYPE
 #define TYPE _Float128
 #endif


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [gcc(refs/users/meissner/heads/work055)] Add IEEE 128-bit min/max support on PowerPC.
@ 2021-06-08 23:37 Michael Meissner
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Meissner @ 2021-06-08 23:37 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:a92c2c2c1018a72a3bb2344211cff1facccdfbe5

commit a92c2c2c1018a72a3bb2344211cff1facccdfbe5
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Tue Jun 8 19:36:38 2021 -0400

    Add IEEE 128-bit min/max support on PowerPC.
    
    This patch adds the support for the IEEE 128-bit floating point C minimum and
    maximum instructions.  The next patch will add the support for using the
    compare and set mask instruction to implement conditional moves.
    
    This patch does not try to re-use the code used for SF/DF min/max
    support.  It defines a separate insn for the IEEE 128-bit support.  It
    uses the code iterator <minmax> to simplify adding both operations.
    
    GCC will not convert ternary operations into using min/max instructions
    provided in this patch unless the user uses -Ofast or similar switches due to
    issues with NaNs.  The next patch that adds conditional move instructions will
    enable the ternary conversion in many cases.
    
    Note the code for fixing float128-minmax.c has been moved to a separate
    patch.
    
    gcc/
    2021-06-08  Michael Meissner  <meissner@linux.ibm.com>
    
            * config/rs6000/rs6000.c (rs6000_emit_minmax): Add support for ISA
            3.1 IEEE 128-bit floating point xsmaxcqp and xsmincqp
            instructions.
            * config/rs6000/rs6000.md (s<minmax><mode>3, IEEE128 iterator):
            New insns.
    
    gcc/testsuite/
    2021-06-08  Michael Meissner  <meissner@linux.ibm.com>
    
            * gcc.target/powerpc/float128-minmax-2.c: New test.

Diff:
---
 gcc/config/rs6000/rs6000.c                           |  3 ++-
 gcc/config/rs6000/rs6000.md                          | 11 +++++++++++
 gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c | 15 +++++++++++++++
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index b01bb5c8191..1651788df6a 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -16103,7 +16103,8 @@ rs6000_emit_minmax (rtx dest, enum rtx_code code, rtx op0, rtx op1)
   /* VSX/altivec have direct min/max insns.  */
   if ((code == SMAX || code == SMIN)
       && (VECTOR_UNIT_ALTIVEC_OR_VSX_P (mode)
-	  || (mode == SFmode && VECTOR_UNIT_VSX_P (DFmode))))
+	  || (mode == SFmode && VECTOR_UNIT_VSX_P (DFmode))
+	  || (TARGET_POWER10 && TARGET_FLOAT128_HW && FLOAT128_IEEE_P (mode))))
     {
       emit_insn (gen_rtx_SET (dest, gen_rtx_fmt_ee (code, mode, op0, op1)));
       return;
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 3f59b544f6a..064c3a2d9d6 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -5214,6 +5214,17 @@
 }
   [(set_attr "type" "fp")])
 
+;; Min/max for ISA 3.1 IEEE 128-bit floating point
+(define_insn "s<minmax><mode>3"
+  [(set (match_operand:IEEE128 0 "altivec_register_operand" "=v")
+	(fp_minmax:IEEE128
+	 (match_operand:IEEE128 1 "altivec_register_operand" "v")
+	 (match_operand:IEEE128 2 "altivec_register_operand" "v")))]
+  "TARGET_POWER10"
+  "xs<minmax>cqp %0,%1,%2"
+  [(set_attr "type" "vecfloat")
+   (set_attr "size" "128")])
+
 ;; The conditional move instructions allow us to perform max and min operations
 ;; even when we don't have the appropriate max/min instruction using the FSEL
 ;; instruction.
diff --git a/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c b/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c
new file mode 100644
index 00000000000..c71ba08c9f8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c
@@ -0,0 +1,15 @@
+/* { dg-require-effective-target ppc_float128_hw } */
+/* { dg-require-effective-target power10_ok } */
+/* { dg-options "-mdejagnu-cpu=power10 -O2 -ffast-math" } */
+
+#ifndef TYPE
+#define TYPE _Float128
+#endif
+
+/* Test that the fminf128/fmaxf128 functions generate if/then/else and not a
+   call.  */
+TYPE f128_min (TYPE a, TYPE b) { return __builtin_fminf128 (a, b); }
+TYPE f128_max (TYPE a, TYPE b) { return __builtin_fmaxf128 (a, b); }
+
+/* { dg-final { scan-assembler {\mxsmaxcqp\M} } } */
+/* { dg-final { scan-assembler {\mxsmincqp\M} } } */


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [gcc(refs/users/meissner/heads/work055)] Add IEEE 128-bit min/max support on PowerPC.
@ 2021-06-08 16:49 Michael Meissner
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Meissner @ 2021-06-08 16:49 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:ad3a024c9cfdb64e20c0e3fac5bd54a1b25b9528

commit ad3a024c9cfdb64e20c0e3fac5bd54a1b25b9528
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Tue Jun 8 12:49:34 2021 -0400

    Add IEEE 128-bit min/max support on PowerPC.
    
    This patch adds the support for the IEEE 128-bit floating point C minimum and
    maximum instructions.  The next patch will add the support for using the
    compare and set mask instruction to implement conditional moves.
    
    This patch does not try to re-use the code used for SF/DF min/max
    support.  It defines a separate insn for the IEEE 128-bit support.  It
    uses the code iterator <minmax> to simplify adding both operations.
    
    GCC will not convert ternary operations into using min/max instructions
    provided in this patch unless the user uses -Ofast or similar switches due to
    issues with NaNs.  The next patch that adds conditional move instructions will
    enable the ternary conversion in many cases.
    
    The float128-minmax.c test generates the xsmincqp and xsmaxcqp
    instructions on power10.  This patch adjusts the test to accomidate this.
    
    gcc/
    2021-06-08  Michael Meissner  <meissner@linux.ibm.com>
    
            * config/rs6000/rs6000.c (rs6000_emit_minmax): Add support for ISA
            3.1 IEEE 128-bit floating point xsmaxcqp and xsmincqp
            instructions.
            * config/rs6000/rs6000.md (s<minmax><mode>3, IEEE128 iterator):
            New insns.
    
    gcc/testsuite/
    2021-06-08  Michael Meissner  <meissner@linux.ibm.com>
    
            * gcc.target/powerpc/float128-minmax-2.c: New test.
            * gcc.target/powerpc/float128-minmax.c: Adjust expected code for
            power10.
            * lib/target-supports.exp (check_effective_target_has_arch_pwr10):
            New target support.

Diff:
---
 gcc/config/rs6000/rs6000.c                           |  3 ++-
 gcc/config/rs6000/rs6000.md                          | 11 +++++++++++
 gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c | 15 +++++++++++++++
 gcc/testsuite/gcc.target/powerpc/float128-minmax.c   |  8 +++++---
 gcc/testsuite/lib/target-supports.exp                | 10 ++++++++++
 5 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index b01bb5c8191..1651788df6a 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -16103,7 +16103,8 @@ rs6000_emit_minmax (rtx dest, enum rtx_code code, rtx op0, rtx op1)
   /* VSX/altivec have direct min/max insns.  */
   if ((code == SMAX || code == SMIN)
       && (VECTOR_UNIT_ALTIVEC_OR_VSX_P (mode)
-	  || (mode == SFmode && VECTOR_UNIT_VSX_P (DFmode))))
+	  || (mode == SFmode && VECTOR_UNIT_VSX_P (DFmode))
+	  || (TARGET_POWER10 && TARGET_FLOAT128_HW && FLOAT128_IEEE_P (mode))))
     {
       emit_insn (gen_rtx_SET (dest, gen_rtx_fmt_ee (code, mode, op0, op1)));
       return;
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 3f59b544f6a..064c3a2d9d6 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -5214,6 +5214,17 @@
 }
   [(set_attr "type" "fp")])
 
+;; Min/max for ISA 3.1 IEEE 128-bit floating point
+(define_insn "s<minmax><mode>3"
+  [(set (match_operand:IEEE128 0 "altivec_register_operand" "=v")
+	(fp_minmax:IEEE128
+	 (match_operand:IEEE128 1 "altivec_register_operand" "v")
+	 (match_operand:IEEE128 2 "altivec_register_operand" "v")))]
+  "TARGET_POWER10"
+  "xs<minmax>cqp %0,%1,%2"
+  [(set_attr "type" "vecfloat")
+   (set_attr "size" "128")])
+
 ;; The conditional move instructions allow us to perform max and min operations
 ;; even when we don't have the appropriate max/min instruction using the FSEL
 ;; instruction.
diff --git a/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c b/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c
new file mode 100644
index 00000000000..c71ba08c9f8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c
@@ -0,0 +1,15 @@
+/* { dg-require-effective-target ppc_float128_hw } */
+/* { dg-require-effective-target power10_ok } */
+/* { dg-options "-mdejagnu-cpu=power10 -O2 -ffast-math" } */
+
+#ifndef TYPE
+#define TYPE _Float128
+#endif
+
+/* Test that the fminf128/fmaxf128 functions generate if/then/else and not a
+   call.  */
+TYPE f128_min (TYPE a, TYPE b) { return __builtin_fminf128 (a, b); }
+TYPE f128_max (TYPE a, TYPE b) { return __builtin_fmaxf128 (a, b); }
+
+/* { dg-final { scan-assembler {\mxsmaxcqp\M} } } */
+/* { dg-final { scan-assembler {\mxsmincqp\M} } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/float128-minmax.c b/gcc/testsuite/gcc.target/powerpc/float128-minmax.c
index fe397518f2f..efb4ce232f9 100644
--- a/gcc/testsuite/gcc.target/powerpc/float128-minmax.c
+++ b/gcc/testsuite/gcc.target/powerpc/float128-minmax.c
@@ -1,6 +1,5 @@
-/* { dg-do compile { target lp64 } } */
 /* { dg-require-effective-target powerpc_p9vector_ok } */
-/* { dg-require-effective-target float128 } */
+/* { dg-require-effective-target powerpc_float128_hw } */
 /* { dg-options "-mpower9-vector -O2 -ffast-math" } */
 
 #ifndef TYPE
@@ -12,5 +11,8 @@
 TYPE f128_min (TYPE a, TYPE b) { return __builtin_fminf128 (a, b); }
 TYPE f128_max (TYPE a, TYPE b) { return __builtin_fmaxf128 (a, b); }
 
-/* { dg-final { scan-assembler     {\mxscmpuqp\M} } } */
+/* Adjust code power10 which has native min/max instructions.  */
+/* { dg-final { scan-assembler     {\mxscmpuqp\M} } { target { ! has_arch_pwr10 } } } */
+/* { dg-final { scan-assembler     {\mxsmincqp\M} } { target {   has_arch_pwr10 } } } */
+/* { dg-final { scan-assembler     {\mxsmaxcqp\M} } { target {   has_arch_pwr10 } } } */
 /* { dg-final { scan-assembler-not {\mbl\M}       } } */
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 7f78c5593ac..789723fb287 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -6127,6 +6127,16 @@ proc check_effective_target_has_arch_pwr9 { } {
 	}]
 }
 
+proc check_effective_target_has_arch_pwr10 { } {
+	return [check_no_compiler_messages arch_pwr10 assembly {
+		#ifndef _ARCH_PWR10
+		#error does not have power10 support.
+		#else
+		/* "has power10 support" */
+		#endif
+	}]
+}
+
 # Return 1 if this is a PowerPC target supporting -mcpu=power10.
 # Limit this to 64-bit linux systems for now until other targets support
 # power10.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [gcc(refs/users/meissner/heads/work055)] Add IEEE 128-bit min/max support on PowerPC.
@ 2021-06-08  4:19 Michael Meissner
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Meissner @ 2021-06-08  4:19 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:baeec6a8972350088ca7c84793e5cf34343d3d73

commit baeec6a8972350088ca7c84793e5cf34343d3d73
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Tue Jun 8 00:19:39 2021 -0400

    Add IEEE 128-bit min/max support on PowerPC.
    
    This patch adds the support for the IEEE 128-bit floating point C minimum and
    maximum instructions.  The next patch will add the support for using the
    compare and set mask instruction to implement conditional moves.
    
    This patch does not try to re-use the code used for SF/DF min/max
    support.  It defines a separate insn for the IEEE 128-bit support.  It
    uses the code iterator <minmax> to simplify adding both operations.
    
    GCC will not convert ternary operations into using min/max instructions
    provided in this patch unless the user uses -Ofast or similar switches due to
    issues with NaNs.  The next patch that adds conditional move instructions will
    enable the ternary conversion in many cases.
    
    The float128-minmax.c test generates the xsmincqp and xsmaxcqp
    instructions on power10.  This patch adjusts the test to accomidate this.
    
    gcc/
    2021-06-08  Michael Meissner  <meissner@linux.ibm.com>
    
            * config/rs6000/rs6000.c (rs6000_emit_minmax): Add support for ISA
            3.1 IEEE 128-bit floating point xsmaxcqp and xsmincqp
            instructions.
            * config/rs6000/rs6000.md (s<minmax><mode>3, IEEE128 iterator):
            New insns.
    
    gcc/testsuite/
    2021-06-08  Michael Meissner  <meissner@linux.ibm.com>
    
            * gcc.target/powerpc/float128-minmax-2.c: New test.
            * gcc.target/powerpc/float128-minmax.c: Adjust expected code for
            power10.
            * lib/target-supports.exp (check_effective_target_has_arch_pwr10):
            New target support.

Diff:
---
 gcc/config/rs6000/rs6000.c                           |  3 ++-
 gcc/config/rs6000/rs6000.md                          | 11 +++++++++++
 gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c | 15 +++++++++++++++
 gcc/testsuite/gcc.target/powerpc/float128-minmax.c   |  9 ++++++---
 gcc/testsuite/lib/target-supports.exp                | 10 ++++++++++
 5 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index b01bb5c8191..1651788df6a 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -16103,7 +16103,8 @@ rs6000_emit_minmax (rtx dest, enum rtx_code code, rtx op0, rtx op1)
   /* VSX/altivec have direct min/max insns.  */
   if ((code == SMAX || code == SMIN)
       && (VECTOR_UNIT_ALTIVEC_OR_VSX_P (mode)
-	  || (mode == SFmode && VECTOR_UNIT_VSX_P (DFmode))))
+	  || (mode == SFmode && VECTOR_UNIT_VSX_P (DFmode))
+	  || (TARGET_POWER10 && TARGET_FLOAT128_HW && FLOAT128_IEEE_P (mode))))
     {
       emit_insn (gen_rtx_SET (dest, gen_rtx_fmt_ee (code, mode, op0, op1)));
       return;
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 3f59b544f6a..064c3a2d9d6 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -5214,6 +5214,17 @@
 }
   [(set_attr "type" "fp")])
 
+;; Min/max for ISA 3.1 IEEE 128-bit floating point
+(define_insn "s<minmax><mode>3"
+  [(set (match_operand:IEEE128 0 "altivec_register_operand" "=v")
+	(fp_minmax:IEEE128
+	 (match_operand:IEEE128 1 "altivec_register_operand" "v")
+	 (match_operand:IEEE128 2 "altivec_register_operand" "v")))]
+  "TARGET_POWER10"
+  "xs<minmax>cqp %0,%1,%2"
+  [(set_attr "type" "vecfloat")
+   (set_attr "size" "128")])
+
 ;; The conditional move instructions allow us to perform max and min operations
 ;; even when we don't have the appropriate max/min instruction using the FSEL
 ;; instruction.
diff --git a/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c b/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c
new file mode 100644
index 00000000000..c71ba08c9f8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c
@@ -0,0 +1,15 @@
+/* { dg-require-effective-target ppc_float128_hw } */
+/* { dg-require-effective-target power10_ok } */
+/* { dg-options "-mdejagnu-cpu=power10 -O2 -ffast-math" } */
+
+#ifndef TYPE
+#define TYPE _Float128
+#endif
+
+/* Test that the fminf128/fmaxf128 functions generate if/then/else and not a
+   call.  */
+TYPE f128_min (TYPE a, TYPE b) { return __builtin_fminf128 (a, b); }
+TYPE f128_max (TYPE a, TYPE b) { return __builtin_fmaxf128 (a, b); }
+
+/* { dg-final { scan-assembler {\mxsmaxcqp\M} } } */
+/* { dg-final { scan-assembler {\mxsmincqp\M} } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/float128-minmax.c b/gcc/testsuite/gcc.target/powerpc/float128-minmax.c
index fe397518f2f..ba6fd996d72 100644
--- a/gcc/testsuite/gcc.target/powerpc/float128-minmax.c
+++ b/gcc/testsuite/gcc.target/powerpc/float128-minmax.c
@@ -1,7 +1,7 @@
 /* { dg-do compile { target lp64 } } */
 /* { dg-require-effective-target powerpc_p9vector_ok } */
 /* { dg-require-effective-target float128 } */
-/* { dg-options "-mpower9-vector -O2 -ffast-math" } */
+/* { dg-options "-O2 -ffast-math" } */
 
 #ifndef TYPE
 #define TYPE _Float128
@@ -12,5 +12,8 @@
 TYPE f128_min (TYPE a, TYPE b) { return __builtin_fminf128 (a, b); }
 TYPE f128_max (TYPE a, TYPE b) { return __builtin_fmaxf128 (a, b); }
 
-/* { dg-final { scan-assembler     {\mxscmpuqp\M} } } */
-/* { dg-final { scan-assembler-not {\mbl\M}       } } */
+/* Note power10 has native min/max instructions.  */
+/* { dg-final { scan-assembler-times {\mxscmpuqp\M} 2 { target { ! has_arch_pwr10 } } } } */
+/* { dg-final { scan-assembler-times {\mxsmincqp\M} 1 { target {   has_arch_pwr10 } } } } */
+/* { dg-final { scan-assembler-times {\mxsmaxcqp\M} 1 { target {   has_arch_pwr10 } } } } */
+/* { dg-final { scan-assembler-not   {\mbl\M}       } } */
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 7f78c5593ac..789723fb287 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -6127,6 +6127,16 @@ proc check_effective_target_has_arch_pwr9 { } {
 	}]
 }
 
+proc check_effective_target_has_arch_pwr10 { } {
+	return [check_no_compiler_messages arch_pwr10 assembly {
+		#ifndef _ARCH_PWR10
+		#error does not have power10 support.
+		#else
+		/* "has power10 support" */
+		#endif
+	}]
+}
+
 # Return 1 if this is a PowerPC target supporting -mcpu=power10.
 # Limit this to 64-bit linux systems for now until other targets support
 # power10.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [gcc(refs/users/meissner/heads/work055)] Add IEEE 128-bit min/max support on PowerPC.
@ 2021-06-08  3:49 Michael Meissner
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Meissner @ 2021-06-08  3:49 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5075e1bf8216f9ce123f920d198c7759244c4dbb

commit 5075e1bf8216f9ce123f920d198c7759244c4dbb
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Mon Jun 7 23:48:55 2021 -0400

    Add IEEE 128-bit min/max support on PowerPC.
    
    This patch adds the support for the IEEE 128-bit floating point C minimum and
    maximum instructions.  The next patch will add the support for using the
    compare and set mask instruction to implement conditional moves.
    
    This patch does not try to re-use the code used for SF/DF min/max
    support.  It defines a separate insn for the IEEE 128-bit support.  It
    uses the code iterator <minmax> to simplify adding both operations.
    
    GCC will not convert ternary operations into using min/max instructions
    provided in this patch unless the user uses -Ofast or similar switches due to
    issues with NaNs.  The next patch that adds conditional move instructions will
    enable the ternary conversion in many cases.
    
    The float128-minmax.c test generates the xsmincqp and xsmaxcqp
    instructions on power10.  This patch adjusts the test to accomidate this.
    
    gcc/
    2021-06-07  Michael Meissner  <meissner@linux.ibm.com>
    
            * config/rs6000/rs6000.c (rs6000_emit_minmax): Add support for ISA
            3.1 IEEE 128-bit floating point xsmaxcqp and xsmincqp
            instructions.
            * config/rs6000/rs6000.md (s<minmax><mode>3, IEEE128 iterator):
            New insns.
    
    gcc/testsuite/
    2021-06-07  Michael Meissner  <meissner@linux.ibm.com>
    
            * gcc.target/powerpc/float128-minmax-2.c: New test.
            * gcc.target/powerpc/float128-minmax.c: Adjust expected code for
            power10.
            * lib/target-supports.exp (check_effective_target_has_arch_pwr10):
            New target support.

Diff:
---
 gcc/config/rs6000/rs6000.c                           |  3 ++-
 gcc/config/rs6000/rs6000.md                          | 11 +++++++++++
 gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c | 15 +++++++++++++++
 gcc/testsuite/gcc.target/powerpc/float128-minmax.c   |  7 +++++--
 gcc/testsuite/lib/target-supports.exp                | 10 ++++++++++
 5 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index b01bb5c8191..1651788df6a 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -16103,7 +16103,8 @@ rs6000_emit_minmax (rtx dest, enum rtx_code code, rtx op0, rtx op1)
   /* VSX/altivec have direct min/max insns.  */
   if ((code == SMAX || code == SMIN)
       && (VECTOR_UNIT_ALTIVEC_OR_VSX_P (mode)
-	  || (mode == SFmode && VECTOR_UNIT_VSX_P (DFmode))))
+	  || (mode == SFmode && VECTOR_UNIT_VSX_P (DFmode))
+	  || (TARGET_POWER10 && TARGET_FLOAT128_HW && FLOAT128_IEEE_P (mode))))
     {
       emit_insn (gen_rtx_SET (dest, gen_rtx_fmt_ee (code, mode, op0, op1)));
       return;
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 3f59b544f6a..064c3a2d9d6 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -5214,6 +5214,17 @@
 }
   [(set_attr "type" "fp")])
 
+;; Min/max for ISA 3.1 IEEE 128-bit floating point
+(define_insn "s<minmax><mode>3"
+  [(set (match_operand:IEEE128 0 "altivec_register_operand" "=v")
+	(fp_minmax:IEEE128
+	 (match_operand:IEEE128 1 "altivec_register_operand" "v")
+	 (match_operand:IEEE128 2 "altivec_register_operand" "v")))]
+  "TARGET_POWER10"
+  "xs<minmax>cqp %0,%1,%2"
+  [(set_attr "type" "vecfloat")
+   (set_attr "size" "128")])
+
 ;; The conditional move instructions allow us to perform max and min operations
 ;; even when we don't have the appropriate max/min instruction using the FSEL
 ;; instruction.
diff --git a/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c b/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c
new file mode 100644
index 00000000000..c71ba08c9f8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c
@@ -0,0 +1,15 @@
+/* { dg-require-effective-target ppc_float128_hw } */
+/* { dg-require-effective-target power10_ok } */
+/* { dg-options "-mdejagnu-cpu=power10 -O2 -ffast-math" } */
+
+#ifndef TYPE
+#define TYPE _Float128
+#endif
+
+/* Test that the fminf128/fmaxf128 functions generate if/then/else and not a
+   call.  */
+TYPE f128_min (TYPE a, TYPE b) { return __builtin_fminf128 (a, b); }
+TYPE f128_max (TYPE a, TYPE b) { return __builtin_fmaxf128 (a, b); }
+
+/* { dg-final { scan-assembler {\mxsmaxcqp\M} } } */
+/* { dg-final { scan-assembler {\mxsmincqp\M} } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/float128-minmax.c b/gcc/testsuite/gcc.target/powerpc/float128-minmax.c
index fe397518f2f..9a5059e2d68 100644
--- a/gcc/testsuite/gcc.target/powerpc/float128-minmax.c
+++ b/gcc/testsuite/gcc.target/powerpc/float128-minmax.c
@@ -1,7 +1,7 @@
 /* { dg-do compile { target lp64 } } */
 /* { dg-require-effective-target powerpc_p9vector_ok } */
 /* { dg-require-effective-target float128 } */
-/* { dg-options "-mpower9-vector -O2 -ffast-math" } */
+/* { dg-options "-O2 -ffast-math" } */
 
 #ifndef TYPE
 #define TYPE _Float128
@@ -12,5 +12,8 @@
 TYPE f128_min (TYPE a, TYPE b) { return __builtin_fminf128 (a, b); }
 TYPE f128_max (TYPE a, TYPE b) { return __builtin_fmaxf128 (a, b); }
 
-/* { dg-final { scan-assembler     {\mxscmpuqp\M} } } */
+/* Note power10 has native min/max instructions.  */
+/* { dg-final { scan-assembler     {\mxscmpuqp\M} } { target { ! has_arch_pwr10 } } } */
+/* { dg-final { scan-assembler     {\mxsmincqp\M} } { target {   has_arch_pwr10 } } } */
+/* { dg-final { scan-assembler     {\mxsmaxcqp\M} } { target {   has_arch_pwr10 } } } */
 /* { dg-final { scan-assembler-not {\mbl\M}       } } */
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 7f78c5593ac..789723fb287 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -6127,6 +6127,16 @@ proc check_effective_target_has_arch_pwr9 { } {
 	}]
 }
 
+proc check_effective_target_has_arch_pwr10 { } {
+	return [check_no_compiler_messages arch_pwr10 assembly {
+		#ifndef _ARCH_PWR10
+		#error does not have power10 support.
+		#else
+		/* "has power10 support" */
+		#endif
+	}]
+}
+
 # Return 1 if this is a PowerPC target supporting -mcpu=power10.
 # Limit this to 64-bit linux systems for now until other targets support
 # power10.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [gcc(refs/users/meissner/heads/work055)] Add IEEE 128-bit min/max support on PowerPC.
@ 2021-06-08  3:05 Michael Meissner
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Meissner @ 2021-06-08  3:05 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:2b254cb79d6c67961f2b77ba4bedff84b55a0661

commit 2b254cb79d6c67961f2b77ba4bedff84b55a0661
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Mon Jun 7 23:04:00 2021 -0400

    Add IEEE 128-bit min/max support on PowerPC.
    
    This patch adds the support for the IEEE 128-bit floating point C minimum and
    maximum instructions.  The next patch will add the support for using the
    compare and set mask instruction to implement conditional moves.
    
    This patch does not try to re-use the code used for SF/DF min/max
    support.  It defines a separate insn for the IEEE 128-bit support.  It
    uses the code iterator <minmax> to simplify adding both operations.
    
    GCC will not convert ternary operations into using min/max instructions
    provided in this patch unless the user uses -Ofast or similar switches due to
    issues with NaNs.  The next patch that adds conditional move instructions will
    enable the ternary conversion in many cases.
    
    The float128-minmax.c test generates the xsmincqp and xsmaxcqp
    instructions on power10.  This patch adjusts the test to accomidate this.
    
    gcc/
    2021-06-07  Michael Meissner  <meissner@linux.ibm.com>
    
            * config/rs6000/rs6000.c (rs6000_emit_minmax): Add support for ISA
            3.1 IEEE 128-bit floating point xsmaxcqp and xsmincqp
            instructions.
            * config/rs6000/rs6000.md (s<minmax><mode>3, IEEE128 iterator):
            New insns.
    
    gcc/testsuite/
    2021-06-07  Michael Meissner  <meissner@linux.ibm.com>
    
            * gcc.target/powerpc/float128-minmax-2.c: New test.
            * gcc.target/powerpc/float128-minmax.c: Adjust expected code for
            power10.
            * lib/target-supports.exp (check_effective_target_has_arch_pwr10):
            New target support.

Diff:
---
 gcc/config/rs6000/rs6000.c                           |  3 ++-
 gcc/config/rs6000/rs6000.md                          | 11 +++++++++++
 gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c | 15 +++++++++++++++
 gcc/testsuite/gcc.target/powerpc/float128-minmax.c   |  7 +++++--
 gcc/testsuite/lib/target-supports.exp                | 10 ++++++++++
 5 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index b01bb5c8191..1651788df6a 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -16103,7 +16103,8 @@ rs6000_emit_minmax (rtx dest, enum rtx_code code, rtx op0, rtx op1)
   /* VSX/altivec have direct min/max insns.  */
   if ((code == SMAX || code == SMIN)
       && (VECTOR_UNIT_ALTIVEC_OR_VSX_P (mode)
-	  || (mode == SFmode && VECTOR_UNIT_VSX_P (DFmode))))
+	  || (mode == SFmode && VECTOR_UNIT_VSX_P (DFmode))
+	  || (TARGET_POWER10 && TARGET_FLOAT128_HW && FLOAT128_IEEE_P (mode))))
     {
       emit_insn (gen_rtx_SET (dest, gen_rtx_fmt_ee (code, mode, op0, op1)));
       return;
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 3f59b544f6a..064c3a2d9d6 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -5214,6 +5214,17 @@
 }
   [(set_attr "type" "fp")])
 
+;; Min/max for ISA 3.1 IEEE 128-bit floating point
+(define_insn "s<minmax><mode>3"
+  [(set (match_operand:IEEE128 0 "altivec_register_operand" "=v")
+	(fp_minmax:IEEE128
+	 (match_operand:IEEE128 1 "altivec_register_operand" "v")
+	 (match_operand:IEEE128 2 "altivec_register_operand" "v")))]
+  "TARGET_POWER10"
+  "xs<minmax>cqp %0,%1,%2"
+  [(set_attr "type" "vecfloat")
+   (set_attr "size" "128")])
+
 ;; The conditional move instructions allow us to perform max and min operations
 ;; even when we don't have the appropriate max/min instruction using the FSEL
 ;; instruction.
diff --git a/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c b/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c
new file mode 100644
index 00000000000..c71ba08c9f8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c
@@ -0,0 +1,15 @@
+/* { dg-require-effective-target ppc_float128_hw } */
+/* { dg-require-effective-target power10_ok } */
+/* { dg-options "-mdejagnu-cpu=power10 -O2 -ffast-math" } */
+
+#ifndef TYPE
+#define TYPE _Float128
+#endif
+
+/* Test that the fminf128/fmaxf128 functions generate if/then/else and not a
+   call.  */
+TYPE f128_min (TYPE a, TYPE b) { return __builtin_fminf128 (a, b); }
+TYPE f128_max (TYPE a, TYPE b) { return __builtin_fmaxf128 (a, b); }
+
+/* { dg-final { scan-assembler {\mxsmaxcqp\M} } } */
+/* { dg-final { scan-assembler {\mxsmincqp\M} } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/float128-minmax.c b/gcc/testsuite/gcc.target/powerpc/float128-minmax.c
index fe397518f2f..cdff6943bc3 100644
--- a/gcc/testsuite/gcc.target/powerpc/float128-minmax.c
+++ b/gcc/testsuite/gcc.target/powerpc/float128-minmax.c
@@ -1,7 +1,7 @@
 /* { dg-do compile { target lp64 } } */
 /* { dg-require-effective-target powerpc_p9vector_ok } */
 /* { dg-require-effective-target float128 } */
-/* { dg-options "-mpower9-vector -O2 -ffast-math" } */
+/* { dg-options "-O2 -ffast-math" } */
 
 #ifndef TYPE
 #define TYPE _Float128
@@ -12,5 +12,8 @@
 TYPE f128_min (TYPE a, TYPE b) { return __builtin_fminf128 (a, b); }
 TYPE f128_max (TYPE a, TYPE b) { return __builtin_fmaxf128 (a, b); }
 
-/* { dg-final { scan-assembler     {\mxscmpuqp\M} } } */
+/* Note power10 has native min/max instructions.  */
+/* { dg-final { scan-assembler     {\mxscmpuqp\M} } target { ! has_arch_pwr10 } } */
+/* { dg-final { scan-assembler     {\mxsmincqp\M} } target { has_arch_pwr10 } } */
+/* { dg-final { scan-assembler     {\mxsmaxcqp\M} } target { has_arch_pwr10 } } */
 /* { dg-final { scan-assembler-not {\mbl\M}       } } */
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 7f78c5593ac..789723fb287 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -6127,6 +6127,16 @@ proc check_effective_target_has_arch_pwr9 { } {
 	}]
 }
 
+proc check_effective_target_has_arch_pwr10 { } {
+	return [check_no_compiler_messages arch_pwr10 assembly {
+		#ifndef _ARCH_PWR10
+		#error does not have power10 support.
+		#else
+		/* "has power10 support" */
+		#endif
+	}]
+}
+
 # Return 1 if this is a PowerPC target supporting -mcpu=power10.
 # Limit this to 64-bit linux systems for now until other targets support
 # power10.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [gcc(refs/users/meissner/heads/work055)] Add IEEE 128-bit min/max support on PowerPC.
@ 2021-06-08  2:23 Michael Meissner
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Meissner @ 2021-06-08  2:23 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:dce04f488a720f2a5e37e78fa558163ac65e9587

commit dce04f488a720f2a5e37e78fa558163ac65e9587
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Mon Jun 7 22:22:46 2021 -0400

    Add IEEE 128-bit min/max support on PowerPC.
    
    This patch adds the support for the IEEE 128-bit floating point C minimum and
    maximum instructions.  The next patch will add the support for using the
    compare and set mask instruction to implement conditional moves.
    
    This patch does not try to re-use the code used for SF/DF min/max
    support.  It defines a separate insn for the IEEE 128-bit support.  It
    uses the code iterator <minmax> to simplify adding both operations.
    
    GCC will not convert ternary operations into using min/max instructions
    provided in this patch unless the user uses -Ofast or similar switches due to
    issues with NaNs.  The next patch that adds conditional move instructions will
    enable the ternary conversion in many cases.
    
    The float128-minmax.c is not done if the target is power10, since the
    support xsmincqp and xsmaxcqp support will generate different
    instructions.
    
    gcc/
    2021-06-07  Michael Meissner  <meissner@linux.ibm.com>
    
            * config/rs6000/rs6000.c (rs6000_emit_minmax): Add support for ISA
            3.1 IEEE 128-bit floating point xsmaxcqp and xsmincqp instructions.
            * config/rs6000/rs6000.md (s<minmax><mode>3, IEEE128 iterator):
            New insns.
    
    gcc/testsuite/
    2021-06-07  Michael Meissner  <meissner@linux.ibm.com>
    
            * gcc.target/powerpc/float128-minmax-2.c: New test.
            * gcc.target/powerpc/float128-minmax.c: Do not run on power10.
            * lib/target-supports.exp (check_effective_target_has_arch_pwr10):
            New target support.

Diff:
---
 gcc/config/rs6000/rs6000.c                           |  3 ++-
 gcc/config/rs6000/rs6000.md                          | 11 +++++++++++
 gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c | 15 +++++++++++++++
 gcc/testsuite/gcc.target/powerpc/float128-minmax.c   |  7 +++++--
 gcc/testsuite/lib/target-supports.exp                | 10 ++++++++++
 5 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index b01bb5c8191..1651788df6a 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -16103,7 +16103,8 @@ rs6000_emit_minmax (rtx dest, enum rtx_code code, rtx op0, rtx op1)
   /* VSX/altivec have direct min/max insns.  */
   if ((code == SMAX || code == SMIN)
       && (VECTOR_UNIT_ALTIVEC_OR_VSX_P (mode)
-	  || (mode == SFmode && VECTOR_UNIT_VSX_P (DFmode))))
+	  || (mode == SFmode && VECTOR_UNIT_VSX_P (DFmode))
+	  || (TARGET_POWER10 && TARGET_FLOAT128_HW && FLOAT128_IEEE_P (mode))))
     {
       emit_insn (gen_rtx_SET (dest, gen_rtx_fmt_ee (code, mode, op0, op1)));
       return;
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 3f59b544f6a..064c3a2d9d6 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -5214,6 +5214,17 @@
 }
   [(set_attr "type" "fp")])
 
+;; Min/max for ISA 3.1 IEEE 128-bit floating point
+(define_insn "s<minmax><mode>3"
+  [(set (match_operand:IEEE128 0 "altivec_register_operand" "=v")
+	(fp_minmax:IEEE128
+	 (match_operand:IEEE128 1 "altivec_register_operand" "v")
+	 (match_operand:IEEE128 2 "altivec_register_operand" "v")))]
+  "TARGET_POWER10"
+  "xs<minmax>cqp %0,%1,%2"
+  [(set_attr "type" "vecfloat")
+   (set_attr "size" "128")])
+
 ;; The conditional move instructions allow us to perform max and min operations
 ;; even when we don't have the appropriate max/min instruction using the FSEL
 ;; instruction.
diff --git a/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c b/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c
new file mode 100644
index 00000000000..c71ba08c9f8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/float128-minmax-2.c
@@ -0,0 +1,15 @@
+/* { dg-require-effective-target ppc_float128_hw } */
+/* { dg-require-effective-target power10_ok } */
+/* { dg-options "-mdejagnu-cpu=power10 -O2 -ffast-math" } */
+
+#ifndef TYPE
+#define TYPE _Float128
+#endif
+
+/* Test that the fminf128/fmaxf128 functions generate if/then/else and not a
+   call.  */
+TYPE f128_min (TYPE a, TYPE b) { return __builtin_fminf128 (a, b); }
+TYPE f128_max (TYPE a, TYPE b) { return __builtin_fmaxf128 (a, b); }
+
+/* { dg-final { scan-assembler {\mxsmaxcqp\M} } } */
+/* { dg-final { scan-assembler {\mxsmincqp\M} } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/float128-minmax.c b/gcc/testsuite/gcc.target/powerpc/float128-minmax.c
index fe397518f2f..76bb88b170d 100644
--- a/gcc/testsuite/gcc.target/powerpc/float128-minmax.c
+++ b/gcc/testsuite/gcc.target/powerpc/float128-minmax.c
@@ -1,7 +1,10 @@
 /* { dg-do compile { target lp64 } } */
-/* { dg-require-effective-target powerpc_p9vector_ok } */
+/* { dg-require-effective-target powerpc_p9vector_ok && ! has_arch_pwr10 } */
 /* { dg-require-effective-target float128 } */
-/* { dg-options "-mpower9-vector -O2 -ffast-math" } */
+/* { dg-options "-O2 -ffast-math" } */
+
+/* We don't run this test on power10 because power10 has instructions to
+   implement min/max directly.  */
 
 #ifndef TYPE
 #define TYPE _Float128
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 7f78c5593ac..789723fb287 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -6127,6 +6127,16 @@ proc check_effective_target_has_arch_pwr9 { } {
 	}]
 }
 
+proc check_effective_target_has_arch_pwr10 { } {
+	return [check_no_compiler_messages arch_pwr10 assembly {
+		#ifndef _ARCH_PWR10
+		#error does not have power10 support.
+		#else
+		/* "has power10 support" */
+		#endif
+	}]
+}
+
 # Return 1 if this is a PowerPC target supporting -mcpu=power10.
 # Limit this to 64-bit linux systems for now until other targets support
 # power10.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-06-08 23:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08  0:31 [gcc(refs/users/meissner/heads/work055)] Add IEEE 128-bit min/max support on PowerPC Michael Meissner
2021-06-08  2:23 Michael Meissner
2021-06-08  3:05 Michael Meissner
2021-06-08  3:49 Michael Meissner
2021-06-08  4:19 Michael Meissner
2021-06-08 16:49 Michael Meissner
2021-06-08 23:37 Michael Meissner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).