mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
middle-end: allow expand_vector_broadcast to broadcast QImode to BImode vector [PR 124280]
A boolean value is in QImode, but a vector of booleans is in VxxBImode. And both AArch64 SVE and RISC-V V have vec_duplicatevXXbi accepting a QI scalar. Allow this case. PR middle-end/124280 gcc/ * optabs.cc (expand_vector_broadcast): Allow broadcasting QImode to BImode vector. gcc/testsuite/ * gcc.c-torture/compile/pr124280.c: New test.
This commit is contained in:
@@ -429,7 +429,8 @@ force_expand_binop (machine_mode mode, optab binoptab,
|
||||
}
|
||||
|
||||
/* Create a new vector value in VMODE with all elements set to OP. If OP
|
||||
is not a constant, the mode of it must be the element mode of VMODE.
|
||||
is not a constant, the mode of it must be the element mode of VMODE
|
||||
(if the element is BImode, additionally OP is allowed to be in QImode).
|
||||
If OP is a constant, then the return value will be a constant. */
|
||||
|
||||
rtx
|
||||
@@ -440,7 +441,9 @@ expand_vector_broadcast (machine_mode vmode, rtx op)
|
||||
|
||||
gcc_checking_assert (VECTOR_MODE_P (vmode));
|
||||
gcc_checking_assert (CONST_INT_P (op)
|
||||
|| GET_MODE_INNER (vmode) == GET_MODE (op));
|
||||
|| GET_MODE_INNER (vmode) == GET_MODE (op)
|
||||
|| (GET_MODE_INNER (vmode) == BImode
|
||||
&& GET_MODE (op) == QImode));
|
||||
|
||||
if (valid_for_const_vector_p (vmode, op))
|
||||
return gen_const_vec_duplicate (vmode, op);
|
||||
|
||||
12
gcc/testsuite/gcc.c-torture/compile/pr124280.c
Normal file
12
gcc/testsuite/gcc.c-torture/compile/pr124280.c
Normal file
@@ -0,0 +1,12 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-additional-options "-fno-trapping-math -mcpu=neoverse-v2" { target aarch64-*-* } } */
|
||||
|
||||
void foo(int *__restrict a, int pblh, int *__restrict res, int n)
|
||||
{
|
||||
int wts = a[0];
|
||||
for(int i = 0; i < n;i++)
|
||||
{
|
||||
if (a[i] < pblh && wts > 0)
|
||||
res[i] = a[i];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user