This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix altivec PR c/6290
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Geoff Keating <geoffk at redhat dot com>, gcc-patches at gcc dot gnu dot org, bernds at redhat dot com
- Date: Mon, 22 Apr 2002 12:58:46 +1000
- Subject: Re: [PATCH] Fix altivec PR c/6290
- References: <20020415173320.S32482@sunsite.ms.mff.cuni.cz>
On Mon, Apr 15, 2002 at 05:33:20PM +0200, Jakub Jelinek wrote:
hi jakub. hi bernd.
is either you or bernd going to commit this? i haven't taken a look
at bernd's version, but this one looks ok.
regarding the other testcase that you found, i bet it gets fixed by
bernd's combine patch.
oh yeah, and you can't use CONST0_RTX like i thought, because you don't
have the mode. i suppose we could change easy_vec_const to have a mode.
aldy
> Hi!
>
> PR c/6290 is failing because initialize_uninitialized_subregs
> added
> (insn 70 48 4 (set (reg/v:V4SI 117)
> (const_vector:V4SI[
> (const_int 0 [0x0])
> (const_int 0 [0x0])
> (const_int 0 [0x0])
> (const_int 0 [0x0])
> ] )) -1 (nil)
> (nil))
>
> but due to bug in easy_vector_constant rs6000_emit_move used force_const_mem
> on it which cannot work when no new pseudos can be created.
> easy_vector_constant never returned anything but 0.
> The following patch changes easy_vector_constant so that it does what
> the comment in it say.
>
> altivec-5.c is a testcase for this, broken before this patch, fixed
> afterwards. While minimalizing the testcase, I found another testcase
> which ICEs gcc on ppc no matter whether this patch is in or not.
>
> Ok to commit?
>
> 2002-04-15 Jakub Jelinek <jakub@redhat.com>
>
> PR c/6290
> * config/rs6000/rs6000.c (easy_vector_constant): Return 1 if the
> CONST_VECTOR is { 0, ... 0 }.
>
> * gcc.dg/altivec-5.c: New test.
> * gcc.dg/altivec-6.c: New test.
>
> --- gcc/config/rs6000/rs6000.c.jj Tue Apr 9 16:14:50 2002
> +++ gcc/config/rs6000/rs6000.c Mon Apr 15 15:32:33 2002
> @@ -1221,18 +1221,24 @@ easy_vector_constant (op)
> with CONST0_RTX for the current mode, but let's be safe
> instead. */
>
> - if (GET_CODE (elt) == CONST_INT && INTVAL (elt) != 0)
> - return 0;
> -
> - if (GET_CODE (elt) == CONST_DOUBLE
> - && (CONST_DOUBLE_LOW (elt) != 0
> - || CONST_DOUBLE_HIGH (elt) != 0))
> - return 0;
> + switch (GET_CODE (elt))
> + {
> + case CONST_INT:
> + if (INTVAL (elt) != 0)
> + return 0;
> + break;
> + case CONST_DOUBLE:
> + if (CONST_DOUBLE_LOW (elt) != 0 || CONST_DOUBLE_HIGH (elt) != 0)
> + return 0;
> + break;
> + default:
> + return 0;
> + }
> }
>
> /* We could probably generate a few other constants trivially, but
> gcc doesn't generate them yet. FIXME later. */
> - return 0;
> + return 1;
> }
>
> /* Return 1 if the operand is the constant 0. This works for scalars
> --- gcc/testsuite/gcc.dg/altivec-5.c.jj Mon Apr 15 17:00:40 2002
> +++ gcc/testsuite/gcc.dg/altivec-5.c Mon Apr 15 17:02:46 2002
> @@ -0,0 +1,22 @@
> +/* PR c/6290
> + This testcase ICEd because easy_vector_constant was broken. */
> +/* { dg-do compile { target powerpc-*-* } } */
> +/* { dg-options "-maltivec -O2 -fno-strict-aliasing" } */
> +
> +#define vector __attribute__((vector_size(16)))
> +
> +register vector signed int reg asm ("%v31");
> +
> +vector signed int a, b;
> +
> +void
> +foo (const unsigned long x)
> +{
> + vector signed int c;
> + unsigned long d;
> +
> + *(unsigned long *) &c = x;
> + if (!__builtin_altivec_vcmpgtsw_p (0, c, b))
> + b = __builtin_altivec_vsumsws (a, reg);
> + __builtin_altivec_stvewx (b, 0, (int *) &d);
> +}
> --- gcc/testsuite/gcc.dg/altivec-6.c.jj Mon Apr 15 17:03:14 2002
> +++ gcc/testsuite/gcc.dg/altivec-6.c Mon Apr 15 17:12:19 2002
> @@ -0,0 +1,12 @@
> +/* { dg-do compile { target powerpc-*-* } } */
> +/* { dg-options "-maltivec -O2" } */
> +
> +#define vector __attribute__((vector_size(16)))
> +
> +void foo (const unsigned long x,
> + vector signed int a, vector signed int b)
> +{
> + unsigned long d;
> +
> + __builtin_altivec_stvewx (b, 0, (int *) &d);
> +}
>
> Jakub