Skip to content

Commit b7dd2e4

Browse files
committed
x86: Fix ix86_expand_vector_init for V*TImode [PR100887]
We have vec_initv4tiv2ti and vec_initv2titi patterns which call ix86_expand_vector_init and assume it works for those modes. For the case of construction from two half-sized vectors, the code assumes it will always succeed, but we have only insn patterns with SImode and DImode element types. QImode and HImode element types are already handled by performing it with same sized vectors with SImode elements and the following patch extends that to V*TImode vectors. 2021-06-04 Jakub Jelinek <[email protected]> PR target/100887 * config/i386/i386-expand.c (ix86_expand_vector_init): Handle concatenation from half-sized modes with TImode elements. * gcc.target/i386/pr100887.c: New test.
1 parent 3011f10 commit b7dd2e4

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

gcc/config/i386/i386-expand.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14610,11 +14610,15 @@ ix86_expand_vector_init (bool mmx_ok, rtx target, rtx vals)
1461014610
if (GET_MODE_NUNITS (GET_MODE (x)) * 2 == n_elts)
1461114611
{
1461214612
rtx ops[2] = { XVECEXP (vals, 0, 0), XVECEXP (vals, 0, 1) };
14613-
if (inner_mode == QImode || inner_mode == HImode)
14613+
if (inner_mode == QImode
14614+
|| inner_mode == HImode
14615+
|| inner_mode == TImode)
1461414616
{
1461514617
unsigned int n_bits = n_elts * GET_MODE_SIZE (inner_mode);
14616-
mode = mode_for_vector (SImode, n_bits / 4).require ();
14617-
inner_mode = mode_for_vector (SImode, n_bits / 8).require ();
14618+
scalar_mode elt_mode = inner_mode == TImode ? DImode : SImode;
14619+
n_bits /= GET_MODE_SIZE (elt_mode);
14620+
mode = mode_for_vector (elt_mode, n_bits).require ();
14621+
inner_mode = mode_for_vector (elt_mode, n_bits / 2).require ();
1461814622
ops[0] = gen_lowpart (inner_mode, ops[0]);
1461914623
ops[1] = gen_lowpart (inner_mode, ops[1]);
1462014624
subtarget = gen_reg_rtx (mode);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* PR target/100887 */
2+
/* { dg-do compile { target int128 } } */
3+
/* { dg-options "-mavx512f" } */
4+
5+
typedef unsigned __int128 U __attribute__((__vector_size__ (64)));
6+
typedef unsigned __int128 V __attribute__((__vector_size__ (32)));
7+
typedef unsigned __int128 W __attribute__((__vector_size__ (16)));
8+
9+
W
10+
foo (U u, V v)
11+
{
12+
return __builtin_shufflevector (u, v, 0);
13+
}

0 commit comments

Comments
 (0)