RISC-V: Add testcases for signed imm SAT_ADD form1
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / pr65947-7.c
blob58c46df5c5473d43df3f15ac2c8fa62eb7b449ae
1 /* { dg-require-effective-target vect_condition } */
3 #include "tree-vect.h"
5 extern void abort (void) __attribute__ ((noreturn));
7 #define N 43
9 /* Condition reduction with comparison is a different type to the data. Will
10 fail to vectorize. */
12 int __attribute__ ((noipa))
13 condition_reduction (short *a, int min_v, int *b)
15 int last = N + 65;
16 short aval;
18 for (int i = 0; i < N; i++)
20 aval = a[i];
21 if (b[i] < min_v)
22 last = aval;
24 return last;
27 int
28 main (void)
30 short a[N] = {
31 31, -32, 133, 324, 335, 36, 37, 45, 11, 65,
32 1, -28, 3, 48, 5, -68, 7, 88, 89, 180,
33 121, -122, 123, 124, -125, 126, 127, 128, 129, 130,
34 11, 12, 13, 14, -15, -16, 17, 18, 19, 20,
35 33, 27, 99
37 int b[N] = {
38 11, -12, -13, 14, 15, 16, 17, 18, 19, 20,
39 21, -22, 23, 24, -25, 26, 27, 28, 29, 30,
40 1, 62, 3, 14, -15, 6, 37, 48, 99, 10,
41 31, -32, 33, 34, -35, 36, 37, 56, 54, 22,
42 73, 2, 87
45 check_vect ();
47 int ret = condition_reduction (a, 16, b);
49 if (ret != 27)
50 abort ();
52 return 0;
55 /* { dg-final { scan-tree-dump "optimizing condition reduction with FOLD_EXTRACT_LAST" "vect" { target vect_fold_extract_last } } } */
56 /* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target aarch64*-*-* } } } */