From: Andrew Pinski Date: Fri, 28 Mar 2008 07:27:11 +0000 (+0000) Subject: re PR target/31334 (Bad codegen for vector initializer with constants prop'd into... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=501fb355e6fa564e8acdcf9ac1c1766c61afd097;p=gcc.git re PR target/31334 (Bad codegen for vector initializer with constants prop'd into a vector initializer) 2008-03-28 Andrew Pinski PR target/31334 * config/rs6000/rs6000.c (rs6000_expand_vector_init): Create a const_vector when all the vectors are constant. 2008-03-28 Andrew Pinski PR target/31334 * gcc.target/powerpc/altivec-25.c: Nnew testcase. From-SVN: r133674 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f55e8a8519a..a5cebe93f94 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-03-28 Andrew Pinski + + PR target/31334 + * config/rs6000/rs6000.c (rs6000_expand_vector_init): Create a + const_vector when all the vectors are constant. + 2008-03-27 Bob Wilson * config/xtensa/xtensa.c (gen_float_relational): Handle unordered diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 593408f56d5..a7997093987 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -2965,6 +2965,7 @@ rs6000_expand_vector_init (rtx target, rtx vals) if (n_var == 0) { + rtx const_vec = gen_rtx_CONST_VECTOR (mode, XVEC (vals, 0)); if (mode != V4SFmode && all_const_zero) { /* Zero register. */ @@ -2972,10 +2973,10 @@ rs6000_expand_vector_init (rtx target, rtx vals) gen_rtx_XOR (mode, target, target))); return; } - else if (mode != V4SFmode && easy_vector_constant (vals, mode)) + else if (mode != V4SFmode && easy_vector_constant (const_vec, mode)) { /* Splat immediate. */ - emit_insn (gen_rtx_SET (VOIDmode, target, vals)); + emit_insn (gen_rtx_SET (VOIDmode, target, const_vec)); return; } else if (all_same) @@ -2983,7 +2984,7 @@ rs6000_expand_vector_init (rtx target, rtx vals) else { /* Load from constant pool. */ - emit_move_insn (target, gen_rtx_CONST_VECTOR (mode, XVEC (vals, 0))); + emit_move_insn (target, const_vec); return; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7b6cda1bbbb..13e59e7413c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-03-28 Andrew Pinski + + PR target/31334 + * gcc.target/powerpc/altivec-25.c: Nnew testcase. + 2008-03-27 Jerry DeLisle PR fortran/35724 diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-25.c b/gcc/testsuite/gcc.target/powerpc/altivec-25.c new file mode 100644 index 00000000000..a3bd0fd001d --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/altivec-25.c @@ -0,0 +1,20 @@ +/* { dg-do compile { target powerpc*-*-* } } */ +/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-options "-maltivec -O2 -Wall" } */ + + +#define vector __attribute__((__vector_size__(16) )) +vector int f() +{ + int t = 4; + return (vector int){t,t,t,t}; +} +vector int f1() +{ + return (vector int){4,4,4,4}; +} + +/* We should be able to materialize the constant vector without + any lvewx instructions as it is constant. */ +/* { dg-final { scan-assembler-not "lvewx" } } */ +