aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <richard@codesourcery.com>2006-10-05 08:25:04 +0000
committerRichard Sandiford <richard@codesourcery.com>2006-10-05 08:25:04 +0000
commitee4f9f81766a38a1edf7d7fe9e7a0261ac4e79d4 (patch)
treed2dedcabc2179d2ab86968275f6800f4d080d80b
parent40bca40597154c5d2fe82977fcb42fdec1b66a2d (diff)
Backport from mainline:
gcc/ 2006-09-20 Richard Sandiford <richard@codesourcery.com> * config/mips/mips.c (CODE_FOR_mips_abs_ps): Delete. * config/mips/mips.md (UNSPEC_ABS_PS): New constant. (UNSPEC_RSQRT1, UNSPEC_RSQRT2, UNSPEC_RECIP1, UNSPEC_RECIP2) (UNSPEC_SINGLE_CC, UNSPEC_SCC): Bump values by 1. (*nmadd<mode>, *nmadd<mode>_fastmath): Require !HONOR_NANS. (*nmsub<mode>, *nmsub<mode>_fastmath): Likewise. (abs<mode>2, neg<mode>2): Likewise. * config/mips/mips-ps-3d.md (mips_abs_ps): New define_expand. (*mips_abs_ps): New define_insn. gcc/testsuite/ 2006-09-20 Richard Sandiford <richard@codesourcery.com> * gcc.target/mips/mips-ps-type.c: Add -ffinite-math-only. * gcc.target/mips/nmadd-2.c: Likewise. * gcc.target/mips/mips-ps-6.c: New test. * gcc.target/mips/neg-abs-1.c: Likewise. * gcc.target/mips/neg-abs-2.c: Likewise. * gcc.target/mips/nmadd-3.c: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/csl/sourcerygxx-4_1@117452 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--ChangeLog.csl27
-rw-r--r--gcc/config/mips/mips-ps-3d.md25
-rw-r--r--gcc/config/mips/mips.c3
-rw-r--r--gcc/config/mips/mips.md35
-rw-r--r--gcc/testsuite/gcc.target/mips/mips-ps-6.c136
-rw-r--r--gcc/testsuite/gcc.target/mips/mips-ps-type.c5
-rw-r--r--gcc/testsuite/gcc.target/mips/neg-abs-1.c13
-rw-r--r--gcc/testsuite/gcc.target/mips/neg-abs-2.c13
-rw-r--r--gcc/testsuite/gcc.target/mips/nmadd-2.c2
-rw-r--r--gcc/testsuite/gcc.target/mips/nmadd-3.c32
10 files changed, 274 insertions, 17 deletions
diff --git a/ChangeLog.csl b/ChangeLog.csl
index 3254f9f6515..9e19cdfd1f1 100644
--- a/ChangeLog.csl
+++ b/ChangeLog.csl
@@ -1,5 +1,32 @@
2006-10-05 Richard Sandiford <richard@codesourcery.com>
+ Backport from mainline:
+
+ gcc/
+ 2006-09-20 Richard Sandiford <richard@codesourcery.com>
+
+ * config/mips/mips.c (CODE_FOR_mips_abs_ps): Delete.
+ * config/mips/mips.md (UNSPEC_ABS_PS): New constant.
+ (UNSPEC_RSQRT1, UNSPEC_RSQRT2, UNSPEC_RECIP1, UNSPEC_RECIP2)
+ (UNSPEC_SINGLE_CC, UNSPEC_SCC): Bump values by 1.
+ (*nmadd<mode>, *nmadd<mode>_fastmath): Require !HONOR_NANS.
+ (*nmsub<mode>, *nmsub<mode>_fastmath): Likewise.
+ (abs<mode>2, neg<mode>2): Likewise.
+ * config/mips/mips-ps-3d.md (mips_abs_ps): New define_expand.
+ (*mips_abs_ps): New define_insn.
+
+ gcc/testsuite/
+ 2006-09-20 Richard Sandiford <richard@codesourcery.com>
+
+ * gcc.target/mips/mips-ps-type.c: Add -ffinite-math-only.
+ * gcc.target/mips/nmadd-2.c: Likewise.
+ * gcc.target/mips/mips-ps-6.c: New test.
+ * gcc.target/mips/neg-abs-1.c: Likewise.
+ * gcc.target/mips/neg-abs-2.c: Likewise.
+ * gcc.target/mips/nmadd-3.c: New test.
+
+2006-10-05 Richard Sandiford <richard@codesourcery.com>
+
gcc/
* config/mips/mips.c (mips_offset_within_object_p): Delete
declaration.
diff --git a/gcc/config/mips/mips-ps-3d.md b/gcc/config/mips/mips-ps-3d.md
index 4d893a6ff41..8bd71734b85 100644
--- a/gcc/config/mips/mips-ps-3d.md
+++ b/gcc/config/mips/mips-ps-3d.md
@@ -276,6 +276,31 @@
[(set_attr "type" "fmul")
(set_attr "mode" "SF")])
+; abs.ps
+(define_expand "mips_abs_ps"
+ [(set (match_operand:V2SF 0 "register_operand")
+ (unspec:V2SF [(match_operand:V2SF 1 "register_operand")]
+ UNSPEC_ABS_PS))]
+ "TARGET_PAIRED_SINGLE_FLOAT"
+{
+ /* If we can ignore NaNs, this operation is equivalent to the
+ rtl ABS code. */
+ if (!HONOR_NANS (V2SFmode))
+ {
+ emit_insn (gen_absv2sf2 (operands[0], operands[1]));
+ DONE;
+ }
+})
+
+(define_insn "*mips_abs_ps"
+ [(set (match_operand:V2SF 0 "register_operand" "=f")
+ (unspec:V2SF [(match_operand:V2SF 1 "register_operand" "f")]
+ UNSPEC_ABS_PS))]
+ "TARGET_PAIRED_SINGLE_FLOAT"
+ "abs.ps\t%0,%1"
+ [(set_attr "type" "fabs")
+ (set_attr "mode" "SF")])
+
;----------------------------------------------------------------------------
; Floating Point Comparisons for Scalars
;----------------------------------------------------------------------------
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index f4e0765094f..73761188d96 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -10013,9 +10013,6 @@ struct builtin_description
CMP_4S_BUILTINS (c, COND), \
CMP_4S_BUILTINS (cabs, COND)
-/* __builtin_mips_abs_ps() maps to the standard absM2 pattern. */
-#define CODE_FOR_mips_abs_ps CODE_FOR_absv2sf2
-
static const struct builtin_description mips_bdesc[] =
{
DIRECT_BUILTIN (pll_ps, MIPS_V2SF_FTYPE_V2SF_V2SF, MASK_PAIRED_SINGLE_FLOAT),
diff --git a/gcc/config/mips/mips.md b/gcc/config/mips/mips.md
index af0b9e71f8b..134c41560a3 100644
--- a/gcc/config/mips/mips.md
+++ b/gcc/config/mips/mips.md
@@ -67,12 +67,13 @@
(UNSPEC_CVT_PW_PS 205)
(UNSPEC_CVT_PS_PW 206)
(UNSPEC_MULR_PS 207)
+ (UNSPEC_ABS_PS 208)
- (UNSPEC_RSQRT1 208)
- (UNSPEC_RSQRT2 209)
- (UNSPEC_RECIP1 210)
- (UNSPEC_RECIP2 211)
- (UNSPEC_SINGLE_CC 212)
+ (UNSPEC_RSQRT1 209)
+ (UNSPEC_RSQRT2 210)
+ (UNSPEC_RECIP1 211)
+ (UNSPEC_RECIP2 212)
+ (UNSPEC_SINGLE_CC 213)
;; MIPS DSP ASE Revision 0.98 3/24/2005
(UNSPEC_ADDQ 300)
@@ -1762,7 +1763,8 @@
(match_operand:ANYF 2 "register_operand" "f"))
(match_operand:ANYF 3 "register_operand" "f"))))]
"ISA_HAS_NMADD_NMSUB && TARGET_FUSED_MADD
- && HONOR_SIGNED_ZEROS (<MODE>mode)"
+ && HONOR_SIGNED_ZEROS (<MODE>mode)
+ && !HONOR_NANS (<MODE>mode)"
"nmadd.<fmt>\t%0,%3,%1,%2"
[(set_attr "type" "fmadd")
(set_attr "mode" "<UNITMODE>")])
@@ -1774,7 +1776,8 @@
(match_operand:ANYF 2 "register_operand" "f"))
(match_operand:ANYF 3 "register_operand" "f")))]
"ISA_HAS_NMADD_NMSUB && TARGET_FUSED_MADD
- && !HONOR_SIGNED_ZEROS (<MODE>mode)"
+ && !HONOR_SIGNED_ZEROS (<MODE>mode)
+ && !HONOR_NANS (<MODE>mode)"
"nmadd.<fmt>\t%0,%3,%1,%2"
[(set_attr "type" "fmadd")
(set_attr "mode" "<UNITMODE>")])
@@ -1786,7 +1789,8 @@
(match_operand:ANYF 3 "register_operand" "f"))
(match_operand:ANYF 1 "register_operand" "f"))))]
"ISA_HAS_NMADD_NMSUB && TARGET_FUSED_MADD
- && HONOR_SIGNED_ZEROS (<MODE>mode)"
+ && HONOR_SIGNED_ZEROS (<MODE>mode)
+ && !HONOR_NANS (<MODE>mode)"
"nmsub.<fmt>\t%0,%1,%2,%3"
[(set_attr "type" "fmadd")
(set_attr "mode" "<UNITMODE>")])
@@ -1798,7 +1802,8 @@
(mult:ANYF (match_operand:ANYF 2 "register_operand" "f")
(match_operand:ANYF 3 "register_operand" "f"))))]
"ISA_HAS_NMADD_NMSUB && TARGET_FUSED_MADD
- && !HONOR_SIGNED_ZEROS (<MODE>mode)"
+ && !HONOR_SIGNED_ZEROS (<MODE>mode)
+ && !HONOR_NANS (<MODE>mode)"
"nmsub.<fmt>\t%0,%1,%2,%3"
[(set_attr "type" "fmadd")
(set_attr "mode" "<UNITMODE>")])
@@ -1969,10 +1974,14 @@
;; Do not use the integer abs macro instruction, since that signals an
;; exception on -2147483648 (sigh).
+;; abs.fmt is an arithmetic instruction and treats all NaN inputs as
+;; invalid; it does not clear their sign bits. We therefore can't use
+;; abs.fmt if the signs of NaNs matter.
+
(define_insn "abs<mode>2"
[(set (match_operand:ANYF 0 "register_operand" "=f")
(abs:ANYF (match_operand:ANYF 1 "register_operand" "f")))]
- ""
+ "!HONOR_NANS (<MODE>mode)"
"abs.<fmt>\t%0,%1"
[(set_attr "type" "fabs")
(set_attr "mode" "<UNITMODE>")])
@@ -2021,10 +2030,14 @@
[(set_attr "type" "arith")
(set_attr "mode" "DI")])
+;; neg.fmt is an arithmetic instruction and treats all NaN inputs as
+;; invalid; it does not flip their sign bit. We therefore can't use
+;; neg.fmt if the signs of NaNs matter.
+
(define_insn "neg<mode>2"
[(set (match_operand:ANYF 0 "register_operand" "=f")
(neg:ANYF (match_operand:ANYF 1 "register_operand" "f")))]
- ""
+ "!HONOR_NANS (<MODE>mode)"
"neg.<fmt>\t%0,%1"
[(set_attr "type" "fneg")
(set_attr "mode" "<UNITMODE>")])
diff --git a/gcc/testsuite/gcc.target/mips/mips-ps-6.c b/gcc/testsuite/gcc.target/mips/mips-ps-6.c
new file mode 100644
index 00000000000..75de478dc8c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/mips-ps-6.c
@@ -0,0 +1,136 @@
+/* mips-ps-2.c with an extra -ffinite-math-only option. This option
+ changes the way that abs.ps is handled. */
+/* { dg-do run { target mipsisa64*-*-* } } */
+/* { dg-mips-options "-mips64 -O2 -mpaired-single -mhard-float -mgp64 -ffinite-math-only" } */
+
+/* Test MIPS paired-single builtin functions */
+#include <stdlib.h>
+#include <stdio.h>
+
+typedef float v2sf __attribute__ ((vector_size(8)));
+
+int main ()
+{
+ int little_endian;
+ v2sf a, b, c, d;
+ float e,f;
+ int i;
+
+ union { long long ll; int i[2]; } endianness_test;
+ endianness_test.ll = 1;
+ little_endian = endianness_test.i[0];
+
+ /* pll.ps */
+ a = (v2sf) {1, 2};
+ b = (v2sf) {3, 4};
+ c = __builtin_mips_pll_ps (a, b);
+ if (little_endian) // little endian
+ d = (v2sf) {3, 1};
+ else // big endian
+ d = (v2sf) {2, 4};
+
+ if (!__builtin_mips_upper_c_eq_ps (c, d) ||
+ !__builtin_mips_lower_c_eq_ps (c, d))
+ abort ();
+
+ /* pul.ps */
+ a = (v2sf) {1, 2};
+ b = (v2sf) {3, 4};
+ c = __builtin_mips_pul_ps (a, b);
+ if (little_endian) // little endian
+ d = (v2sf) {3, 2};
+ else // big endian
+ d = (v2sf) {1, 4};
+ if (!__builtin_mips_upper_c_eq_ps (c, d) ||
+ !__builtin_mips_lower_c_eq_ps (c, d))
+ abort ();
+
+ /* plu.ps */
+ a = (v2sf) {1, 2};
+ b = (v2sf) {3, 4};
+ c = __builtin_mips_plu_ps (a, b);
+ if (little_endian) // little endian
+ d = (v2sf) {4, 1};
+ else // big endian
+ d = (v2sf) {2, 3};
+ if (!__builtin_mips_upper_c_eq_ps (c, d) ||
+ !__builtin_mips_lower_c_eq_ps (c, d))
+ abort ();
+
+ /* puu.ps */
+ a = (v2sf) {1, 2};
+ b = (v2sf) {3, 4};
+ c = __builtin_mips_puu_ps (a, b);
+ if (little_endian) // little endian
+ d = (v2sf) {4, 2};
+ else // big endian
+ d = (v2sf) {1, 3};
+ if (!__builtin_mips_upper_c_eq_ps (c, d) ||
+ !__builtin_mips_lower_c_eq_ps (c, d))
+ abort ();
+
+ /* cvt.ps.s */
+ e = 3.4;
+ f = 4.5;
+ a = __builtin_mips_cvt_ps_s (e, f);
+ if (little_endian) // little endian
+ b = (v2sf) {4.5, 3.4};
+ else // big endian
+ b = (v2sf) {3.4, 4.5};
+ if (!__builtin_mips_upper_c_eq_ps (a, b) ||
+ !__builtin_mips_lower_c_eq_ps (a, b))
+ abort ();
+
+ /* cvt.s.pl */
+ a = (v2sf) {35.1, 120.2};
+ e = __builtin_mips_cvt_s_pl (a);
+ if (little_endian) // little endian
+ f = 35.1;
+ else // big endian
+ f = 120.2;
+ if (e != f)
+ abort ();
+
+ /* cvt.s.pu */
+ a = (v2sf) {30.0, 100.0};
+ e = __builtin_mips_cvt_s_pu (a);
+ if (little_endian) // little endian
+ f = 100.0;
+ else // big endian
+ f = 30.0;
+ if (e != f)
+ abort ();
+
+ /* abs.ps */
+ a = (v2sf) {-3.4, -5.8};
+ b = __builtin_mips_abs_ps (a);
+ c = (v2sf) {3.4, 5.8};
+ if (!__builtin_mips_upper_c_eq_ps (b, c) ||
+ !__builtin_mips_lower_c_eq_ps (b, c))
+ abort ();
+
+ /* alnv.ps with rs = 4*/
+ a = (v2sf) {1, 2};
+ b = (v2sf) {3, 4};
+ i = 4;
+ c = __builtin_mips_alnv_ps (a, b, i);
+ d = (v2sf) {2, 3};
+
+ if (!__builtin_mips_upper_c_eq_ps (c, d) ||
+ !__builtin_mips_lower_c_eq_ps (c, d))
+ abort ();
+
+ /* alnv.ps with rs = 0 */
+ a = (v2sf) {5, 6};
+ b = (v2sf) {7, 8};
+ i = 0;
+ c = __builtin_mips_alnv_ps (a, b, i);
+ d = (v2sf) {5, 6};
+
+ if (!__builtin_mips_upper_c_eq_ps (c, d) ||
+ !__builtin_mips_lower_c_eq_ps (c, d))
+ abort ();
+
+ printf ("Test Passes\n");
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.target/mips/mips-ps-type.c b/gcc/testsuite/gcc.target/mips/mips-ps-type.c
index cd5566fcbfa..aca3625ab78 100644
--- a/gcc/testsuite/gcc.target/mips/mips-ps-type.c
+++ b/gcc/testsuite/gcc.target/mips/mips-ps-type.c
@@ -1,6 +1,7 @@
-/* Test v2sf calculations */
+/* Test v2sf calculations. The nmadd and nmsub patterns need
+ -ffinite-math-only. */
/* { dg-do compile } */
-/* { dg-mips-options "-mips64 -O2 -mpaired-single -mhard-float -mgp64" } */
+/* { dg-mips-options "-mips64 -O2 -mpaired-single -mhard-float -mgp64 -ffinite-math-only" } */
/* { dg-final { scan-assembler "cvt.ps.s" } } */
/* { dg-final { scan-assembler "mov.ps" } } */
/* { dg-final { scan-assembler "ldc1" } } */
diff --git a/gcc/testsuite/gcc.target/mips/neg-abs-1.c b/gcc/testsuite/gcc.target/mips/neg-abs-1.c
new file mode 100644
index 00000000000..038b8983cb7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/neg-abs-1.c
@@ -0,0 +1,13 @@
+/* Make sure that we use abs.fmt and neg.fmt when the signs of NaNs don't
+ matter. */
+/* { dg-do compile } */
+/* { dg-mips-options "-O2 -mhard-float -ffinite-math-only" } */
+/* { dg-final { scan-assembler "neg.s" } } */
+/* { dg-final { scan-assembler "neg.d" } } */
+/* { dg-final { scan-assembler "abs.s" } } */
+/* { dg-final { scan-assembler "abs.d" } } */
+
+float f1 (float f) { return -f; }
+float f2 (float f) { return __builtin_fabsf (f); }
+double d1 (double d) { return -d; }
+double d2 (double d) { return __builtin_fabs (d); }
diff --git a/gcc/testsuite/gcc.target/mips/neg-abs-2.c b/gcc/testsuite/gcc.target/mips/neg-abs-2.c
new file mode 100644
index 00000000000..5ef08da6f34
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/neg-abs-2.c
@@ -0,0 +1,13 @@
+/* Make sure that we avoid abs.fmt and neg.fmt when the signs of NaNs
+ matter. */
+/* { dg-do compile } */
+/* { dg-mips-options "-O2 -mhard-float -fno-finite-math-only" } */
+/* { dg-final { scan-assembler-not "neg.s" } } */
+/* { dg-final { scan-assembler-not "neg.d" } } */
+/* { dg-final { scan-assembler-not "abs.s" } } */
+/* { dg-final { scan-assembler-not "abs.d" } } */
+
+float f1 (float f) { return -f; }
+float f2 (float f) { return __builtin_fabsf (f); }
+double d1 (double d) { return -d; }
+double d2 (double d) { return __builtin_fabs (d); }
diff --git a/gcc/testsuite/gcc.target/mips/nmadd-2.c b/gcc/testsuite/gcc.target/mips/nmadd-2.c
index 522407a5119..df84a76aad5 100644
--- a/gcc/testsuite/gcc.target/mips/nmadd-2.c
+++ b/gcc/testsuite/gcc.target/mips/nmadd-2.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-mips-options "-O2 -fno-fast-math -mips4 -mhard-float" } */
+/* { dg-mips-options "-O2 -fno-fast-math -ffinite-math-only -mips4 -mhard-float" } */
/* { dg-final { scan-assembler "nmadd.s" } } */
/* { dg-final { scan-assembler "nmadd.d" } } */
/* { dg-final { scan-assembler "nmsub.s" } } */
diff --git a/gcc/testsuite/gcc.target/mips/nmadd-3.c b/gcc/testsuite/gcc.target/mips/nmadd-3.c
new file mode 100644
index 00000000000..381fdef08fb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/nmadd-3.c
@@ -0,0 +1,32 @@
+/* The same code as nmadd-2.c, but compiled with -fno-finite-math-only.
+ We can't use nmadd and nmsub in that case. */
+/* { dg-do compile } */
+/* { dg-mips-options "-O2 -fno-fast-math -fno-finite-math-only -mips4 -mhard-float" } */
+/* { dg-final { scan-assembler-not "nmadd.s" } } */
+/* { dg-final { scan-assembler-not "nmadd.d" } } */
+/* { dg-final { scan-assembler-not "nmsub.s" } } */
+/* { dg-final { scan-assembler-not "nmsub.d" } } */
+
+float
+sub1 (float f, float g, float h)
+{
+ return -((f * g) + h);
+}
+
+double
+sub2 (double f, double g, double h)
+{
+ return -((f * g) + h);
+}
+
+float
+sub3 (float f, float g, float h)
+{
+ return -((f * g) - h);
+}
+
+double
+sub4 (double f, double g, double h)
+{
+ return -((f * g) - h);
+}