From 52c3fdf3e4780f75297515d3c2a3dae9b36586ba Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 2 Jul 2021 10:03:48 -0700 Subject: [PATCH] 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. --- gcc/expr.c | 3 ++- gcc/testsuite/gcc.dg/pr101294.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr101294.c diff --git a/gcc/expr.c b/gcc/expr.c index 025033c9ecf..bd85bbfdd6f 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 00000000000..ca59b35f4be --- /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); +}