summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/aarch64/sve_dup_imm_1.C
blob: 1f7d8a4a9ba821d61e27504219febb3b86de0ad4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* { dg-do compile } */
/* { dg-options "-std=c++11 -O3 -fno-inline -march=armv8-a+sve -fno-tree-loop-distribute-patterns" } */

#include <stdint.h>

#define NUM_ELEMS(TYPE) (1024 / sizeof (TYPE))

#define DEF_SET_IMM(TYPE,IMM,SUFFIX)		\
void set_##TYPE##SUFFIX (TYPE *__restrict__ a)	\
{						\
  for (int i = 0; i < NUM_ELEMS (TYPE); i++)	\
    a[i] = IMM;					\
}

/* --- VALID --- */

DEF_SET_IMM (int8_t, 0, imm_0)
DEF_SET_IMM (int16_t, 0, imm_0)
DEF_SET_IMM (int32_t, 0, imm_0)
DEF_SET_IMM (int64_t, 0, imm_0)

DEF_SET_IMM (int8_t, -1, imm_m1)
DEF_SET_IMM (int16_t, -1, imm_m1)
DEF_SET_IMM (int32_t, -1, imm_m1)
DEF_SET_IMM (int64_t, -1, imm_m1)

DEF_SET_IMM (int8_t, 1, imm_1)
DEF_SET_IMM (int16_t, 1, imm_1)
DEF_SET_IMM (int32_t, 1, imm_1)
DEF_SET_IMM (int64_t, 1, imm_1)

DEF_SET_IMM (int8_t, 127, imm_127)
DEF_SET_IMM (int16_t, 127, imm_127)
DEF_SET_IMM (int32_t, 127, imm_127)
DEF_SET_IMM (int64_t, 127, imm_127)

DEF_SET_IMM (int8_t, -128, imm_m128)
DEF_SET_IMM (int16_t, -128, imm_m128)
DEF_SET_IMM (int32_t, -128, imm_m128)
DEF_SET_IMM (int64_t, -128, imm_m128)

// No uint8_t variant - size too large for a byte
DEF_SET_IMM (int16_t, 256, imm_256)
DEF_SET_IMM (int32_t, 256, imm_256)
DEF_SET_IMM (int64_t, 256, imm_256)

// No uint8_t variant - size too large for a byte
DEF_SET_IMM (int16_t, 32512, imm_32512)
DEF_SET_IMM (int32_t, 32512, imm_32512)
DEF_SET_IMM (int64_t, 32512, imm_32512)

// No uint8_t variant - size too large for a byte
DEF_SET_IMM (int16_t, -32768, imm_m32768)
DEF_SET_IMM (int32_t, -32768, imm_m32768)
DEF_SET_IMM (int64_t, -32768, imm_m32768)

/* gcc will generate:
     dup z0.b, 0x01
*/
DEF_SET_IMM (int16_t, 0x0101, imm_01_pat)
DEF_SET_IMM (int32_t, 0x01010101, imm_01_pat)
DEF_SET_IMM (int64_t, 0x0101010101010101LL, imm_01_pat)

/* gcc will generate:
     dup z0.h, 0x01
*/
DEF_SET_IMM (int32_t, 0x00010001, imm_0001_pat)
DEF_SET_IMM (int64_t, 0x0001000100010001LL, imm_0001_pat)

/* gcc will generate:
     dup z0.b, 0xFE (-2)
*/
DEF_SET_IMM (int16_t, 0xFEFE, imm_FE_pat)
DEF_SET_IMM (int32_t, 0xFEFEFEFE, imm_FE_pat)
DEF_SET_IMM (int64_t, 0xFEFEFEFEFEFEFEFE, imm_FE_pat)

/* gcc will generate:
     dup z0.h, 0xFFFE (-2)
*/
DEF_SET_IMM (int32_t, 0xFFFEFFFE, imm_FFFE_pat)
DEF_SET_IMM (int64_t, 0xFFFEFFFEFFFEFFFELL, imm_FFFE_pat)

/* gcc will generate:
     dup z0.h, 0xFE00
*/
DEF_SET_IMM (int32_t, 0xFE00FE00, imm_FE00_pat)
DEF_SET_IMM (int64_t, 0xFE00FE00FE00FE00LL, imm_FE00_pat)


/* --- INVALID --- */

// This shouldn't generate a dup as it's out of range, but also the compiler
// shouldn't assert!
DEF_SET_IMM (int32_t, 129, imm_m129)
DEF_SET_IMM (int32_t, 32513, imm_32513)
DEF_SET_IMM (int32_t, -32767, imm_m32767)

/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.b, #-1\n} } } */

/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.b, #0\n} } } */

/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.b, #1\n} } } */
/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.h, #1\n} } } */
/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.s, #1\n} } } */
/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.d, #1\n} } } */

/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.b, #127\n} } } */
/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.h, #127\n} } } */
/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.s, #127\n} } } */
/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.d, #127\n} } } */

/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.b, #-128\n} } } */
/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.h, #-128\n} } } */
/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.s, #-128\n} } } */
/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.d, #-128\n} } } */

/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.h, #256\n} } } */
/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.s, #256\n} } } */
/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.d, #256\n} } } */

/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.h, #32512\n} } } */
/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.s, #32512\n} } } */
/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.d, #32512\n} } } */

/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.h, #-32768\n} } } */
/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.s, #-32768\n} } } */
/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.d, #-32768\n} } } */

/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.b, #-2\n} } } */
/* { dg-final { scan-assembler-times {\tmov\tz[0-9]+\.h, #-2\n} 2 } } */

/* { dg-final { scan-assembler {\tmov\tz[0-9]+\.h, #-512\n} } } */