From: H.J. Lu Date: Fri, 2 Jul 2021 17:03:48 +0000 (-0700) Subject: Don't use vec_duplicate on vector in CTOR expansion X-Git-Tag: upstream/12.2.0~6701 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=52c3fdf3e4780f75297515d3c2a3dae9b36586ba;p=platform%2Fupstream%2Fgcc.git Don't use vec_duplicate on vector in CTOR expansion Since vec_duplicate only works on scalar, don't use it on vector in store constructor expansion. gcc/ PR middle-end/101294 * expr.c (store_constructor): Don't use vec_duplicate on vector. gcc/testsuite/ PR middle-end/101294 * gcc.dg/pr101294.c: New test. --- diff --git a/gcc/expr.c b/gcc/expr.c index 025033c..bd85bbf 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -7078,7 +7078,8 @@ store_constructor (tree exp, rtx target, int cleared, poly_int64 size, && eltmode == GET_MODE_INNER (mode) && ((icode = optab_handler (vec_duplicate_optab, mode)) != CODE_FOR_nothing) - && (elt = uniform_vector_p (exp))) + && (elt = uniform_vector_p (exp)) + && !VECTOR_TYPE_P (TREE_TYPE (elt))) { class expand_operand ops[2]; create_output_operand (&ops[0], target, mode); diff --git a/gcc/testsuite/gcc.dg/pr101294.c b/gcc/testsuite/gcc.dg/pr101294.c new file mode 100644 index 0000000..ca59b35 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr101294.c @@ -0,0 +1,15 @@ +/* PR middle-end/101294 */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ +/* { dg-additional-options "-mavx" { target avx } } */ + +typedef __attribute__((__vector_size__ (sizeof (unsigned long long)))) unsigned long long U; +typedef __attribute__((__vector_size__ (4 * sizeof (unsigned long long)))) unsigned long long V; + +extern U x; + +void +foo (void) +{ + x = __builtin_shufflevector ((U){}, (V){}, 3); +}