Ensure the second pivot is really a pivot and it's not in OP1.
PR target/122124
gcc/ChangeLog:
* config/riscv/riscv-v.cc (shuffle_slide_patterns): Check if
the second pivot is in OP1 and improve comments.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/pr122124.c: New test.
int pivot = -1;
for (int i = 0; i < vlen; i++)
{
+ /* The first pivot is in OP1. */
if (pivot == -1 && known_ge (d->perm[i], vec_len))
pivot = i;
if (i > 0 && i != pivot
&& maybe_ne (d->perm[i], d->perm[i - 1] + 1))
{
- if (pivot == -1 || len != 0)
+ /* A second pivot would indicate the vector length and is in OP0. */
+ if (known_ge (d->perm[i], vec_len) || pivot == -1 || len != 0)
return false;
- /* A second pivot would indicate the vector length. */
len = i;
}
}
--- /dev/null
+/* { dg-do run } */
+/* { dg-require-effective-target riscv_v_ok } */
+/* { dg-add-options riscv_v } */
+/* { dg-additional-options "-O0 -std=gnu99" } */
+
+#include <stdint.h>
+#include <stdio.h>
+#define BS_VEC(type, num) type __attribute__((vector_size(num * sizeof(type))))
+uint16_t func_24() {
+ BS_VEC(uint32_t, 4) zero = {0};
+ BS_VEC(uint8_t, 2)
+ BS_VAR_1 = __builtin_shufflevector(
+ (BS_VEC(uint8_t, 4))5,
+ __builtin_convertvector(zero, BS_VEC(uint8_t, 4)), 5, 0);
+ return BS_VAR_1[1];
+}
+int main() {
+ printf("%u\n", func_24());
+}
+
+/* { dg-output "5" } */