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.
This commit is contained in:
H.J. Lu 2021-07-02 10:03:48 -07:00
parent 152f4d0e4d
commit 52c3fdf3e4
2 changed files with 17 additions and 1 deletions

View File

@ -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);

View File

@ -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);
}