From 226cfe61eadd70c97919b77040d8a81b9f65ecb9 Mon Sep 17 00:00:00 2001 From: "J\"orn Rennecke" Date: Thu, 11 Jul 2002 23:53:01 +0000 Subject: [PATCH] simplify-rtx.c (simplify_subreg): Handle floating point CONST_DOUBLEs. gcc: Thu Jul 11 15:39:21 2002 J"orn Rennecke * simplify-rtx.c (simplify_subreg): Handle floating point CONST_DOUBLEs. When an integer subreg of a smaller mode than the element mode is requested, compute a subreg with an integer mode of the same size as the element mode first. testsuite: Thu Jul 11 15:39:21 2002 J"orn Rennecke Andrew Pinski gcc.c-torture/compile/simd-2.c: New testcase. gcc.c-torture/compile/simd-3.c: Likewise. Co-Authored-By: Andrew Pinski From-SVN: r55410 --- gcc/ChangeLog | 7 +++++++ gcc/simplify-rtx.c | 20 ++++++++++++++++++++ gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gcc.c-torture/compile/simd-2.c | 17 +++++++++++++++++ gcc/testsuite/gcc.c-torture/compile/simd-3.c | 17 +++++++++++++++++ 5 files changed, 67 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/compile/simd-2.c create mode 100644 gcc/testsuite/gcc.c-torture/compile/simd-3.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index aece9e4a123..6df98f2a868 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +Fri Jul 12 00:49:36 2002 J"orn Rennecke + + * simplify-rtx.c (simplify_subreg): Handle floating point + CONST_DOUBLEs. When an integer subreg of a smaller mode than + the element mode is requested, compute a subreg with an + integer mode of the same size as the element mode first. + Thu Jul 11 22:02:57 2002 J"orn Rennecke * combine.c (try_combine): When converting a paradoxical subreg diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index ebb464465b8..95a2af09dc2 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -2307,6 +2307,14 @@ simplify_subreg (outermode, op, innermode, byte) for (; n_elts--; i += step) { elt = CONST_VECTOR_ELT (op, i); + if (GET_CODE (elt) == CONST_DOUBLE + && GET_MODE_CLASS (GET_MODE (elt)) == MODE_FLOAT) + { + elt = gen_lowpart_common (int_mode_for_mode (GET_MODE (elt)), + elt); + if (! elt) + return NULL_RTX; + } if (GET_CODE (elt) != CONST_INT) return NULL_RTX; high = high << shift | sum >> (HOST_BITS_PER_WIDE_INT - shift); @@ -2319,6 +2327,18 @@ simplify_subreg (outermode, op, innermode, byte) else return NULL_RTX; } + else if (GET_MODE_CLASS (outermode) == MODE_INT + && (elt_size % GET_MODE_SIZE (outermode) == 0)) + { + enum machine_mode new_mode + = int_mode_for_mode (GET_MODE_INNER (innermode)); + int subbyte = byte % elt_size; + + op = simplify_subreg (new_mode, op, innermode, byte - subbyte); + if (! op) + return NULL_RTX; + return simplify_subreg (outermode, op, new_mode, subbyte); + } else if (GET_MODE_CLASS (outermode) != MODE_VECTOR_INT && GET_MODE_CLASS (outermode) != MODE_VECTOR_FLOAT) /* This shouldn't happen, but let's not do anything stupid. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 13605c9e619..f9f6bb64997 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +Thu Jul 11 15:39:21 2002 J"orn Rennecke + Andrew Pinski + + gcc.c-torture/compile/simd-2.c: New testcase. + gcc.c-torture/compile/simd-3.c: Likewise. + 2002-07-11 Mark Mitchell PR c++/7224 diff --git a/gcc/testsuite/gcc.c-torture/compile/simd-2.c b/gcc/testsuite/gcc.c-torture/compile/simd-2.c new file mode 100644 index 00000000000..694e94f0105 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/simd-2.c @@ -0,0 +1,17 @@ +typedef float floatvect2 __attribute__((mode(V2SF))); + +typedef union +{ + floatvect2 vector; + float f[2]; +}resfloatvect2; + +void tempf(float *x, float *y) +{ + floatvect2 temp={x[0],x[1]}; + floatvect2 temp1={y[0],y[1]}; + resfloatvect2 temp2; + temp2.vector=temp+temp1; + x[0]=temp2.f[0]; + x[1]=temp2.f[1]; +} diff --git a/gcc/testsuite/gcc.c-torture/compile/simd-3.c b/gcc/testsuite/gcc.c-torture/compile/simd-3.c new file mode 100644 index 00000000000..24d2f489e8c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/simd-3.c @@ -0,0 +1,17 @@ +typedef float floatvect2 __attribute__((mode(V2DF))); + +typedef union +{ + floatvect2 vector; + double f[2]; +}resfloatvect2; + +void tempf(double *x, double *y) +{ + floatvect2 temp={x[0],x[1]}; + floatvect2 temp1={y[0],y[1]}; + resfloatvect2 temp2; + temp2.vector=temp+temp1; + x[0]=temp2.f[0]; + x[1]=temp2.f[1]; +}