re PR middle-end/72747 (powerpc: wrong code generated for vec_splats in cascading assignment)

gcc:
2016-10-26  Will Schmidt <will_schmidt@vnet.ibm.com>

        PR middle-end/72747
        * gimplify.c (gimplify_init_constructor): Move emit of constructor
        assignment to earlier in the if/else logic.

testsuite:
2016-10-26  Will Schmidt <will_schmidt@vnet.ibm.com>

        PR middle-end/72747
        * c-c++-common/pr72747-1.c: New test.
        * c-c++-common/pr72747-2.c: Likewise.

From-SVN: r241647
This commit is contained in:
Will Schmidt 2016-10-28 13:28:46 +00:00 committed by Will Schmidt
parent 2a762fe165
commit 0faf9ab4d6
5 changed files with 57 additions and 12 deletions

View File

@ -1,3 +1,9 @@
2016-10-28 Will Schmidt <will_schmidt@vnet.ibm.com>
PR middle-end/72747
* gimplify.c (gimplify_init_constructor): Move emit of constructor
assignment to earlier in the if/else logic.
2016-10-28 Richard Biener <rguenther@suse.de>
PR middle-end/78128

View File

@ -4730,24 +4730,23 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
if (ret == GS_ERROR)
return GS_ERROR;
else if (want_value)
/* If we have gimplified both sides of the initializer but have
not emitted an assignment, do so now. */
if (*expr_p)
{
tree lhs = TREE_OPERAND (*expr_p, 0);
tree rhs = TREE_OPERAND (*expr_p, 1);
gassign *init = gimple_build_assign (lhs, rhs);
gimplify_seq_add_stmt (pre_p, init);
}
if (want_value)
{
*expr_p = object;
return GS_OK;
}
else
{
/* If we have gimplified both sides of the initializer but have
not emitted an assignment, do so now. */
if (*expr_p)
{
tree lhs = TREE_OPERAND (*expr_p, 0);
tree rhs = TREE_OPERAND (*expr_p, 1);
gassign *init = gimple_build_assign (lhs, rhs);
gimplify_seq_add_stmt (pre_p, init);
*expr_p = NULL;
}
*expr_p = NULL;
return GS_ALL_DONE;
}
}

View File

@ -1,3 +1,9 @@
2016-10-26 Will Schmidt <will_schmidt@vnet.ibm.com>
PR middle-end/72747
* c-c++-common/pr72747-1.c: New test.
* c-c++-common/pr72747-2.c: Likewise.
2016-10-28 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
* gcc.target/s390/oscbreak-1.c: New test.

View File

@ -0,0 +1,16 @@
/* { dg-do compile } */
/* { dg-require-effective-target powerpc_altivec_ok } */
/* { dg-options "-maltivec -fdump-tree-gimple" } */
/* PR 72747: Test that cascaded definition is happening for constant vectors. */
#include <altivec.h>
int main (int argc, char *argv[])
{
__vector int v1,v2;
v1 = v2 = vec_splats ((int) 42);
return 0;
}
/* { dg-final { scan-tree-dump-times " v2 = { 42, 42, 42, 42 }" 1 "gimple" } } */

View File

@ -0,0 +1,18 @@
/* { dg-do compile } */
/* { dg-require-effective-target powerpc_altivec_ok } */
/* { dg-options "-c -maltivec -fdump-tree-gimple" } */
/* PR 72747: test that cascaded definition is happening for non constants. */
void foo ()
{
extern int i;
__vector int v,w;
v = w = (vector int) { i };
}
int main (int argc, char *argv[])
{
return 0;
}
/* { dg-final { scan-tree-dump-times " w = {i.0_1}" 1 "gimple" } } */