1 /* { dg-do compile } */
2 /* { dg-options "-O2 -ftree-vectorize" } */
3 
4 #include <stdint.h>
5 
6 #define DEF_LOOP(TYPE, NAME, OP)					\
7   void __attribute__ ((noipa))						\
8   test_##TYPE##_##NAME (TYPE *__restrict r, TYPE *__restrict a,		\
9 			TYPE *__restrict b, TYPE *__restrict c, int n)	\
10   {									\
11     for (int i = 0; i < n; ++i)						\
12       r[i] = a[i] > 20 ? b[i] OP c[i] : b[i];				\
13   }
14 
15 #define TEST_TYPE(T, TYPE) \
16   T (TYPE, shl, <<) \
17   T (TYPE, shr, >>)
18 
19 #define TEST_ALL(T) \
20   TEST_TYPE (T, int32_t) \
21   TEST_TYPE (T, uint32_t) \
22   TEST_TYPE (T, int64_t) \
23   TEST_TYPE (T, uint64_t)
24 
25 TEST_ALL (DEF_LOOP)
26 
27 /* { dg-final { scan-assembler-times {\tlsl\tz[0-9]+\.s, p[0-7]/m,} 2 } } */
28 /* { dg-final { scan-assembler-times {\tlsl\tz[0-9]+\.d, p[0-7]/m,} 2 } } */
29 
30 /* { dg-final { scan-assembler-times {\tasr\tz[0-9]+\.s, p[0-7]/m,} 1 } } */
31 /* { dg-final { scan-assembler-times {\tasr\tz[0-9]+\.d, p[0-7]/m,} 1 } } */
32 
33 /* { dg-final { scan-assembler-times {\tlsr\tz[0-9]+\.s, p[0-7]/m,} 1 } } */
34 /* { dg-final { scan-assembler-times {\tlsr\tz[0-9]+\.d, p[0-7]/m,} 1 } } */
35 
36 /* { dg-final { scan-assembler-not {\tmov\tz[^,]*z} } } */
37 /* { dg-final { scan-assembler-not {\tmovprfx\t} } } */
38 /* { dg-final { scan-assembler-not {\tsel\t} } } */
39