* [PATCH][rs6000] Add vec_init support for 750CL paired vectors and fix movv2sf_paired
@ 2007-10-01 11:13 Revital1 Eres
2007-10-01 17:06 ` David Edelsohn
0 siblings, 1 reply; 2+ messages in thread
From: Revital1 Eres @ 2007-10-01 11:13 UTC (permalink / raw)
To: dje; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1007 bytes --]
Hello,
This patch adds vec_init support for the paired vectors by introducing
a new function: paired_expand_vector_init ().
It also includes a fix to the movv2sf_paired instruction description
regarding move of an easy vector constant.
The patch was tested on ppc64 (only c).
OK for mainline?
Thanks,
Revital
2007-10-01 Revital Eres <eres@il.ibm.com>
* config/rs6000/predicates.md (easy_vector_constant): Return false
for 750CL paired vectors.
* config/rs6000/paired.md (movv2sf_paired): Fix move of easy
vector constant.
(vec_initv2sf): Add new description.
(vconcatsf): Likewise.
* config/rs6000/rs6000-protos.h: Declare paired_expand_vector_init.
* config/rs6000/rs6000.c (paired_expand_vector_init): New function.
testsuite/
* gcc.target/powerpc/paired-8.c: New test.
* gcc.target/powerpc/paired-9.c: New test.
* gcc.target/powerpc/paired-10.c: New test.
(See attached file: patch_paired_init_1_10.txt)
[-- Attachment #2: patch_paired_init_1_10.txt --]
[-- Type: text/plain, Size: 6565 bytes --]
Index: testsuite/gcc.target/powerpc/paired-10.c
===================================================================
--- testsuite/gcc.target/powerpc/paired-10.c (revision 0)
+++ testsuite/gcc.target/powerpc/paired-10.c (revision 0)
@@ -0,0 +1,25 @@
+/* { dg-do compile { target powerpc-*-linux*paired* } } */
+/* { dg-options "-mpaired -m32 -ffinite-math-only " } */
+
+/* Test PowerPC PAIRED extensions. */
+
+#include <paired.h>
+
+static float out[2] __attribute__ ((aligned (8)));
+void
+test_api (float y, float x)
+{
+ vector float c = {x, y};
+ vector float b = {0.0, 8.0};
+ vector float a;
+
+ a = paired_sub (b, c);
+ paired_stx (a, 0, out);
+}
+
+
+int main ()
+{
+ test_api (6, 7);
+ return (0);
+}
Index: testsuite/gcc.target/powerpc/paired-8.c
===================================================================
--- testsuite/gcc.target/powerpc/paired-8.c (revision 0)
+++ testsuite/gcc.target/powerpc/paired-8.c (revision 0)
@@ -0,0 +1,25 @@
+/* { dg-do compile { target powerpc-*-linux*paired* } } */
+/* { dg-options "-mpaired -m32 -ffinite-math-only " } */
+
+/* Test PowerPC PAIRED extensions. */
+
+#include <paired.h>
+
+static float out[2] __attribute__ ((aligned (8)));
+void
+test_api (float x)
+{
+ vector float c = {x, x};
+ vector float b = {60.0, 88.0};
+ vector float a;
+
+ a = paired_sub (b, c);
+ paired_stx (a, 0, out);
+}
+
+
+int main ()
+{
+ test_api (6);
+ return (0);
+}
Index: testsuite/gcc.target/powerpc/paired-9.c
===================================================================
--- testsuite/gcc.target/powerpc/paired-9.c (revision 0)
+++ testsuite/gcc.target/powerpc/paired-9.c (revision 0)
@@ -0,0 +1,25 @@
+/* { dg-do compile { target powerpc-*-linux*paired* } } */
+/* { dg-options "-mpaired -m32 -ffinite-math-only " } */
+
+/* Test PowerPC PAIRED extensions. */
+
+#include <paired.h>
+
+static float out[2] __attribute__ ((aligned (8)));
+void
+test_api (float y, float x)
+{
+ vector float c = {x, 7.0};
+ vector float b = {0.0, 8.0};
+ vector float a;
+
+ a = paired_sub (b, c);
+ paired_stx (a, 0, out);
+}
+
+
+int main ()
+{
+ test_api (6, 7);
+ return (0);
+}
Index: config/rs6000/predicates.md
===================================================================
--- config/rs6000/predicates.md (revision 128891)
+++ config/rs6000/predicates.md (working copy)
@@ -275,6 +275,11 @@
(define_predicate "easy_vector_constant"
(match_code "const_vector")
{
+ /* As the paired vectors are actually FPRs it seems that there is
+ no easy way to load a CONST_VECTOR without using memory. */
+ if (TARGET_PAIRED_FLOAT)
+ return false;
+
if (ALTIVEC_VECTOR_MODE (mode))
{
if (zero_constant (op, mode))
Index: config/rs6000/paired.md
===================================================================
--- config/rs6000/paired.md (revision 128891)
+++ config/rs6000/paired.md (working copy)
@@ -188,7 +188,7 @@
[(set_attr "type" "fp")])
(define_insn "*movv2sf_paired"
- [(set (match_operand:V2SF 0 "nonimmediate_operand" "=Z,f,f,o,r,r,v")
+ [(set (match_operand:V2SF 0 "nonimmediate_operand" "=Z,f,f,o,r,r,f")
(match_operand:V2SF 1 "input_operand" "f,Z,f,r,o,r,W"))]
"TARGET_PAIRED_FLOAT
&& (register_operand (operands[0], V2SFmode)
@@ -202,7 +202,7 @@
case 3: return "#";
case 4: return "#";
case 5: return "#";
- case 6: return output_vec_const_move (operands);
+ case 6: return "#";
default: gcc_unreachable ();
}
}
@@ -352,4 +352,21 @@
"ps_muls1 %0, %1, %2"
[(set_attr "type" "fp")])
+(define_expand "vec_initv2sf"
+ [(match_operand:V2SF 0 "gpc_reg_operand" "=f")
+ (match_operand 1 "" "")]
+ "TARGET_PAIRED_FLOAT"
+{
+ paired_expand_vector_init (operands[0], operands[1]);
+ DONE;
+})
+(define_insn "*vconcatsf"
+ [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
+ (vec_concat:V2SF
+ (match_operand:SF 1 "gpc_reg_operand" "f")
+ (match_operand:SF 2 "gpc_reg_operand" "f")))]
+ "TARGET_PAIRED_FLOAT"
+ "ps_merge00 %0, %1, %2"
+ [(set_attr "type" "fp")])
+
Index: config/rs6000/rs6000-protos.h
===================================================================
--- config/rs6000/rs6000-protos.h (revision 128891)
+++ config/rs6000/rs6000-protos.h (working copy)
@@ -48,6 +48,7 @@
extern rtx gen_easy_altivec_constant (rtx);
extern const char *output_vec_const_move (rtx *);
extern void rs6000_expand_vector_init (rtx, rtx);
+extern void paired_expand_vector_init (rtx, rtx);
extern void rs6000_expand_vector_set (rtx, rtx, int);
extern void rs6000_expand_vector_extract (rtx, rtx, int);
extern void build_mask64_2_operands (rtx, rtx *);
Index: config/rs6000/rs6000.c
===================================================================
--- config/rs6000/rs6000.c (revision 128891)
+++ config/rs6000/rs6000.c (working copy)
@@ -2716,6 +2716,59 @@
return "li %0,%1\n\tevmergelo %0,%0,%0\n\tli %0,%2";
}
+/* Initialize TARGET of vector PAIRED to VALS. */
+
+void
+paired_expand_vector_init (rtx target, rtx vals)
+{
+ enum machine_mode mode = GET_MODE (target);
+ int n_elts = GET_MODE_NUNITS (mode);
+ int n_var = 0;
+ rtx x, new, tmp, constant_op, op1, op2;
+ int i;
+
+ for (i = 0; i < n_elts; ++i)
+ {
+ x = XVECEXP (vals, 0, i);
+ if (!CONSTANT_P (x))
+ ++n_var;
+ }
+ if (n_var == 0)
+ {
+ /* Load from constant pool. */
+ emit_move_insn (target, gen_rtx_CONST_VECTOR (mode, XVEC (vals, 0)));
+ return;
+ }
+
+ if (n_var == 2)
+ {
+ /* The vector is initialized only with non-constants. */
+ new = gen_rtx_VEC_CONCAT (V2SFmode, XVECEXP (vals, 0, 0),
+ XVECEXP (vals, 0, 1));
+
+ emit_move_insn (target, new);
+ return;
+ }
+
+ /* One field is non-constant and the other one is a constant. Load the
+ constant from the constant pool and use ps_merge instruction to
+ construct the whole vector. */
+ op1 = XVECEXP (vals, 0, 0);
+ op2 = XVECEXP (vals, 0, 1);
+
+ constant_op = (CONSTANT_P (op1)) ? op1 : op2;
+
+ tmp = gen_reg_rtx (GET_MODE (constant_op));
+ emit_move_insn (tmp, constant_op);
+
+ if (CONSTANT_P (op1))
+ new = gen_rtx_VEC_CONCAT (V2SFmode, tmp, op2);
+ else
+ new = gen_rtx_VEC_CONCAT (V2SFmode, op1, tmp);
+
+ emit_move_insn (target, new);
+}
+
/* Initialize vector TARGET to VALS. */
void
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH][rs6000] Add vec_init support for 750CL paired vectors and fix movv2sf_paired
2007-10-01 11:13 [PATCH][rs6000] Add vec_init support for 750CL paired vectors and fix movv2sf_paired Revital1 Eres
@ 2007-10-01 17:06 ` David Edelsohn
0 siblings, 0 replies; 2+ messages in thread
From: David Edelsohn @ 2007-10-01 17:06 UTC (permalink / raw)
To: Revital1 Eres; +Cc: gcc-patches
2007-10-01 Revital Eres <eres@il.ibm.com>
* config/rs6000/predicates.md (easy_vector_constant): Return false
for 750CL paired vectors.
* config/rs6000/paired.md (movv2sf_paired): Fix move of easy
vector constant.
(vec_initv2sf): Add new description.
(vconcatsf): Likewise.
* config/rs6000/rs6000-protos.h: Declare paired_expand_vector_init.
* config/rs6000/rs6000.c (paired_expand_vector_init): New function.
testsuite/
* gcc.target/powerpc/paired-8.c: New test.
* gcc.target/powerpc/paired-9.c: New test.
* gcc.target/powerpc/paired-10.c: New test.
Okay.
Thanks, David
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-10-01 17:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-01 11:13 [PATCH][rs6000] Add vec_init support for 750CL paired vectors and fix movv2sf_paired Revital1 Eres
2007-10-01 17:06 ` David Edelsohn
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).