xref: /llvm-project/clang/test/CodeGen/AArch64/sve-vls-bitwise-ops.c (revision 98e747ba56b2f8b51a7c797a3f379d02c545c42b)
1207e5cccSFangrui Song // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
2207e5cccSFangrui Song // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve \
3207e5cccSFangrui Song // RUN: -disable-O0-optnone -mvscale-min=4 -mvscale-max=4 \
4207e5cccSFangrui Song // RUN:  -emit-llvm -o - %s | opt -S -passes=sroa | FileCheck %s
5207e5cccSFangrui Song 
6207e5cccSFangrui Song // REQUIRES: aarch64-registered-target
7207e5cccSFangrui Song 
8207e5cccSFangrui Song #include <arm_sve.h>
9207e5cccSFangrui Song 
10207e5cccSFangrui Song #define N 512
11207e5cccSFangrui Song 
12207e5cccSFangrui Song typedef svint8_t fixed_int8_t __attribute__((arm_sve_vector_bits(N)));
13207e5cccSFangrui Song typedef svint16_t fixed_int16_t __attribute__((arm_sve_vector_bits(N)));
14207e5cccSFangrui Song typedef svint32_t fixed_int32_t __attribute__((arm_sve_vector_bits(N)));
15207e5cccSFangrui Song typedef svint64_t fixed_int64_t __attribute__((arm_sve_vector_bits(N)));
16207e5cccSFangrui Song 
17207e5cccSFangrui Song typedef svuint8_t fixed_uint8_t __attribute__((arm_sve_vector_bits(N)));
18207e5cccSFangrui Song typedef svuint16_t fixed_uint16_t __attribute__((arm_sve_vector_bits(N)));
19207e5cccSFangrui Song typedef svuint32_t fixed_uint32_t __attribute__((arm_sve_vector_bits(N)));
20207e5cccSFangrui Song typedef svuint64_t fixed_uint64_t __attribute__((arm_sve_vector_bits(N)));
21207e5cccSFangrui Song 
22207e5cccSFangrui Song typedef svfloat16_t fixed_float16_t __attribute__((arm_sve_vector_bits(N)));
23207e5cccSFangrui Song typedef svfloat32_t fixed_float32_t __attribute__((arm_sve_vector_bits(N)));
24207e5cccSFangrui Song typedef svfloat64_t fixed_float64_t __attribute__((arm_sve_vector_bits(N)));
25207e5cccSFangrui Song 
26207e5cccSFangrui Song typedef svbool_t fixed_bool_t __attribute__((arm_sve_vector_bits(N)));
27207e5cccSFangrui Song 
28207e5cccSFangrui Song // AND
29207e5cccSFangrui Song 
30207e5cccSFangrui Song // CHECK-LABEL: @and_bool(
31207e5cccSFangrui Song // CHECK-NEXT:  entry:
32207e5cccSFangrui Song // CHECK-NEXT:    [[A_COERCE:%.*]] = bitcast <vscale x 16 x i1> [[TMP0:%.*]] to <vscale x 2 x i8>
33207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <8 x i8> @llvm.vector.extract.v8i8.nxv2i8(<vscale x 2 x i8> [[A_COERCE]], i64 0)
34207e5cccSFangrui Song // CHECK-NEXT:    [[B_COERCE:%.*]] = bitcast <vscale x 16 x i1> [[TMP1:%.*]] to <vscale x 2 x i8>
35207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <8 x i8> @llvm.vector.extract.v8i8.nxv2i8(<vscale x 2 x i8> [[B_COERCE]], i64 0)
36207e5cccSFangrui Song // CHECK-NEXT:    [[AND:%.*]] = and <8 x i8> [[A]], [[B]]
37*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 2 x i8> @llvm.vector.insert.nxv2i8.v8i8(<vscale x 2 x i8> poison, <8 x i8> [[AND]], i64 0)
38207e5cccSFangrui Song // CHECK-NEXT:    [[TMP2:%.*]] = bitcast <vscale x 2 x i8> [[CAST_SCALABLE]] to <vscale x 16 x i1>
39207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 16 x i1> [[TMP2]]
40207e5cccSFangrui Song //
41207e5cccSFangrui Song fixed_bool_t and_bool(fixed_bool_t a, fixed_bool_t b) {
42207e5cccSFangrui Song   return a & b;
43207e5cccSFangrui Song }
44207e5cccSFangrui Song 
45207e5cccSFangrui Song // CHECK-LABEL: @and_i8(
46207e5cccSFangrui Song // CHECK-NEXT:  entry:
47207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <64 x i8> @llvm.vector.extract.v64i8.nxv16i8(<vscale x 16 x i8> [[A_COERCE:%.*]], i64 0)
48207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <64 x i8> @llvm.vector.extract.v64i8.nxv16i8(<vscale x 16 x i8> [[B_COERCE:%.*]], i64 0)
49207e5cccSFangrui Song // CHECK-NEXT:    [[AND:%.*]] = and <64 x i8> [[A]], [[B]]
50*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v64i8(<vscale x 16 x i8> poison, <64 x i8> [[AND]], i64 0)
51207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 16 x i8> [[CAST_SCALABLE]]
52207e5cccSFangrui Song //
53207e5cccSFangrui Song fixed_int8_t and_i8(fixed_int8_t a, fixed_int8_t b) {
54207e5cccSFangrui Song   return a & b;
55207e5cccSFangrui Song }
56207e5cccSFangrui Song 
57207e5cccSFangrui Song // CHECK-LABEL: @and_i16(
58207e5cccSFangrui Song // CHECK-NEXT:  entry:
59207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <32 x i16> @llvm.vector.extract.v32i16.nxv8i16(<vscale x 8 x i16> [[A_COERCE:%.*]], i64 0)
60207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <32 x i16> @llvm.vector.extract.v32i16.nxv8i16(<vscale x 8 x i16> [[B_COERCE:%.*]], i64 0)
61207e5cccSFangrui Song // CHECK-NEXT:    [[AND:%.*]] = and <32 x i16> [[A]], [[B]]
62*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 8 x i16> @llvm.vector.insert.nxv8i16.v32i16(<vscale x 8 x i16> poison, <32 x i16> [[AND]], i64 0)
63207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 8 x i16> [[CAST_SCALABLE]]
64207e5cccSFangrui Song //
65207e5cccSFangrui Song fixed_int16_t and_i16(fixed_int16_t a, fixed_int16_t b) {
66207e5cccSFangrui Song   return a & b;
67207e5cccSFangrui Song }
68207e5cccSFangrui Song 
69207e5cccSFangrui Song // CHECK-LABEL: @and_i32(
70207e5cccSFangrui Song // CHECK-NEXT:  entry:
71207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <16 x i32> @llvm.vector.extract.v16i32.nxv4i32(<vscale x 4 x i32> [[A_COERCE:%.*]], i64 0)
72207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <16 x i32> @llvm.vector.extract.v16i32.nxv4i32(<vscale x 4 x i32> [[B_COERCE:%.*]], i64 0)
73207e5cccSFangrui Song // CHECK-NEXT:    [[AND:%.*]] = and <16 x i32> [[A]], [[B]]
74*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 4 x i32> @llvm.vector.insert.nxv4i32.v16i32(<vscale x 4 x i32> poison, <16 x i32> [[AND]], i64 0)
75207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 4 x i32> [[CAST_SCALABLE]]
76207e5cccSFangrui Song //
77207e5cccSFangrui Song fixed_int32_t and_i32(fixed_int32_t a, fixed_int32_t b) {
78207e5cccSFangrui Song   return a & b;
79207e5cccSFangrui Song }
80207e5cccSFangrui Song 
81207e5cccSFangrui Song // CHECK-LABEL: @and_i64(
82207e5cccSFangrui Song // CHECK-NEXT:  entry:
83207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <8 x i64> @llvm.vector.extract.v8i64.nxv2i64(<vscale x 2 x i64> [[A_COERCE:%.*]], i64 0)
84207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <8 x i64> @llvm.vector.extract.v8i64.nxv2i64(<vscale x 2 x i64> [[B_COERCE:%.*]], i64 0)
85207e5cccSFangrui Song // CHECK-NEXT:    [[AND:%.*]] = and <8 x i64> [[A]], [[B]]
86*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 2 x i64> @llvm.vector.insert.nxv2i64.v8i64(<vscale x 2 x i64> poison, <8 x i64> [[AND]], i64 0)
87207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 2 x i64> [[CAST_SCALABLE]]
88207e5cccSFangrui Song //
89207e5cccSFangrui Song fixed_int64_t and_i64(fixed_int64_t a, fixed_int64_t b) {
90207e5cccSFangrui Song   return a & b;
91207e5cccSFangrui Song }
92207e5cccSFangrui Song 
93207e5cccSFangrui Song // CHECK-LABEL: @and_u8(
94207e5cccSFangrui Song // CHECK-NEXT:  entry:
95207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <64 x i8> @llvm.vector.extract.v64i8.nxv16i8(<vscale x 16 x i8> [[A_COERCE:%.*]], i64 0)
96207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <64 x i8> @llvm.vector.extract.v64i8.nxv16i8(<vscale x 16 x i8> [[B_COERCE:%.*]], i64 0)
97207e5cccSFangrui Song // CHECK-NEXT:    [[AND:%.*]] = and <64 x i8> [[A]], [[B]]
98*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v64i8(<vscale x 16 x i8> poison, <64 x i8> [[AND]], i64 0)
99207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 16 x i8> [[CAST_SCALABLE]]
100207e5cccSFangrui Song //
101207e5cccSFangrui Song fixed_uint8_t and_u8(fixed_uint8_t a, fixed_uint8_t b) {
102207e5cccSFangrui Song   return a & b;
103207e5cccSFangrui Song }
104207e5cccSFangrui Song 
105207e5cccSFangrui Song // CHECK-LABEL: @and_u16(
106207e5cccSFangrui Song // CHECK-NEXT:  entry:
107207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <32 x i16> @llvm.vector.extract.v32i16.nxv8i16(<vscale x 8 x i16> [[A_COERCE:%.*]], i64 0)
108207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <32 x i16> @llvm.vector.extract.v32i16.nxv8i16(<vscale x 8 x i16> [[B_COERCE:%.*]], i64 0)
109207e5cccSFangrui Song // CHECK-NEXT:    [[AND:%.*]] = and <32 x i16> [[A]], [[B]]
110*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 8 x i16> @llvm.vector.insert.nxv8i16.v32i16(<vscale x 8 x i16> poison, <32 x i16> [[AND]], i64 0)
111207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 8 x i16> [[CAST_SCALABLE]]
112207e5cccSFangrui Song //
113207e5cccSFangrui Song fixed_uint16_t and_u16(fixed_uint16_t a, fixed_uint16_t b) {
114207e5cccSFangrui Song   return a & b;
115207e5cccSFangrui Song }
116207e5cccSFangrui Song 
117207e5cccSFangrui Song // CHECK-LABEL: @and_u32(
118207e5cccSFangrui Song // CHECK-NEXT:  entry:
119207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <16 x i32> @llvm.vector.extract.v16i32.nxv4i32(<vscale x 4 x i32> [[A_COERCE:%.*]], i64 0)
120207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <16 x i32> @llvm.vector.extract.v16i32.nxv4i32(<vscale x 4 x i32> [[B_COERCE:%.*]], i64 0)
121207e5cccSFangrui Song // CHECK-NEXT:    [[AND:%.*]] = and <16 x i32> [[A]], [[B]]
122*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 4 x i32> @llvm.vector.insert.nxv4i32.v16i32(<vscale x 4 x i32> poison, <16 x i32> [[AND]], i64 0)
123207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 4 x i32> [[CAST_SCALABLE]]
124207e5cccSFangrui Song //
125207e5cccSFangrui Song fixed_uint32_t and_u32(fixed_uint32_t a, fixed_uint32_t b) {
126207e5cccSFangrui Song   return a & b;
127207e5cccSFangrui Song }
128207e5cccSFangrui Song 
129207e5cccSFangrui Song // CHECK-LABEL: @and_u64(
130207e5cccSFangrui Song // CHECK-NEXT:  entry:
131207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <8 x i64> @llvm.vector.extract.v8i64.nxv2i64(<vscale x 2 x i64> [[A_COERCE:%.*]], i64 0)
132207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <8 x i64> @llvm.vector.extract.v8i64.nxv2i64(<vscale x 2 x i64> [[B_COERCE:%.*]], i64 0)
133207e5cccSFangrui Song // CHECK-NEXT:    [[AND:%.*]] = and <8 x i64> [[A]], [[B]]
134*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 2 x i64> @llvm.vector.insert.nxv2i64.v8i64(<vscale x 2 x i64> poison, <8 x i64> [[AND]], i64 0)
135207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 2 x i64> [[CAST_SCALABLE]]
136207e5cccSFangrui Song //
137207e5cccSFangrui Song fixed_uint64_t and_u64(fixed_uint64_t a, fixed_uint64_t b) {
138207e5cccSFangrui Song   return a & b;
139207e5cccSFangrui Song }
140207e5cccSFangrui Song 
141207e5cccSFangrui Song // OR
142207e5cccSFangrui Song 
143207e5cccSFangrui Song // CHECK-LABEL: @or_bool(
144207e5cccSFangrui Song // CHECK-NEXT:  entry:
145207e5cccSFangrui Song // CHECK-NEXT:    [[A_COERCE:%.*]] = bitcast <vscale x 16 x i1> [[TMP0:%.*]] to <vscale x 2 x i8>
146207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <8 x i8> @llvm.vector.extract.v8i8.nxv2i8(<vscale x 2 x i8> [[A_COERCE]], i64 0)
147207e5cccSFangrui Song // CHECK-NEXT:    [[B_COERCE:%.*]] = bitcast <vscale x 16 x i1> [[TMP1:%.*]] to <vscale x 2 x i8>
148207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <8 x i8> @llvm.vector.extract.v8i8.nxv2i8(<vscale x 2 x i8> [[B_COERCE]], i64 0)
149207e5cccSFangrui Song // CHECK-NEXT:    [[OR:%.*]] = or <8 x i8> [[A]], [[B]]
150*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 2 x i8> @llvm.vector.insert.nxv2i8.v8i8(<vscale x 2 x i8> poison, <8 x i8> [[OR]], i64 0)
151207e5cccSFangrui Song // CHECK-NEXT:    [[TMP2:%.*]] = bitcast <vscale x 2 x i8> [[CAST_SCALABLE]] to <vscale x 16 x i1>
152207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 16 x i1> [[TMP2]]
153207e5cccSFangrui Song //
154207e5cccSFangrui Song fixed_bool_t or_bool(fixed_bool_t a, fixed_bool_t b) {
155207e5cccSFangrui Song   return a | b;
156207e5cccSFangrui Song }
157207e5cccSFangrui Song 
158207e5cccSFangrui Song // CHECK-LABEL: @or_i8(
159207e5cccSFangrui Song // CHECK-NEXT:  entry:
160207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <64 x i8> @llvm.vector.extract.v64i8.nxv16i8(<vscale x 16 x i8> [[A_COERCE:%.*]], i64 0)
161207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <64 x i8> @llvm.vector.extract.v64i8.nxv16i8(<vscale x 16 x i8> [[B_COERCE:%.*]], i64 0)
162207e5cccSFangrui Song // CHECK-NEXT:    [[OR:%.*]] = or <64 x i8> [[A]], [[B]]
163*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v64i8(<vscale x 16 x i8> poison, <64 x i8> [[OR]], i64 0)
164207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 16 x i8> [[CAST_SCALABLE]]
165207e5cccSFangrui Song //
166207e5cccSFangrui Song fixed_int8_t or_i8(fixed_int8_t a, fixed_int8_t b) {
167207e5cccSFangrui Song   return a | b;
168207e5cccSFangrui Song }
169207e5cccSFangrui Song 
170207e5cccSFangrui Song // CHECK-LABEL: @or_i16(
171207e5cccSFangrui Song // CHECK-NEXT:  entry:
172207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <32 x i16> @llvm.vector.extract.v32i16.nxv8i16(<vscale x 8 x i16> [[A_COERCE:%.*]], i64 0)
173207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <32 x i16> @llvm.vector.extract.v32i16.nxv8i16(<vscale x 8 x i16> [[B_COERCE:%.*]], i64 0)
174207e5cccSFangrui Song // CHECK-NEXT:    [[OR:%.*]] = or <32 x i16> [[A]], [[B]]
175*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 8 x i16> @llvm.vector.insert.nxv8i16.v32i16(<vscale x 8 x i16> poison, <32 x i16> [[OR]], i64 0)
176207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 8 x i16> [[CAST_SCALABLE]]
177207e5cccSFangrui Song //
178207e5cccSFangrui Song fixed_int16_t or_i16(fixed_int16_t a, fixed_int16_t b) {
179207e5cccSFangrui Song   return a | b;
180207e5cccSFangrui Song }
181207e5cccSFangrui Song 
182207e5cccSFangrui Song // CHECK-LABEL: @or_i32(
183207e5cccSFangrui Song // CHECK-NEXT:  entry:
184207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <16 x i32> @llvm.vector.extract.v16i32.nxv4i32(<vscale x 4 x i32> [[A_COERCE:%.*]], i64 0)
185207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <16 x i32> @llvm.vector.extract.v16i32.nxv4i32(<vscale x 4 x i32> [[B_COERCE:%.*]], i64 0)
186207e5cccSFangrui Song // CHECK-NEXT:    [[OR:%.*]] = or <16 x i32> [[A]], [[B]]
187*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 4 x i32> @llvm.vector.insert.nxv4i32.v16i32(<vscale x 4 x i32> poison, <16 x i32> [[OR]], i64 0)
188207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 4 x i32> [[CAST_SCALABLE]]
189207e5cccSFangrui Song //
190207e5cccSFangrui Song fixed_int32_t or_i32(fixed_int32_t a, fixed_int32_t b) {
191207e5cccSFangrui Song   return a | b;
192207e5cccSFangrui Song }
193207e5cccSFangrui Song 
194207e5cccSFangrui Song // CHECK-LABEL: @or_i64(
195207e5cccSFangrui Song // CHECK-NEXT:  entry:
196207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <8 x i64> @llvm.vector.extract.v8i64.nxv2i64(<vscale x 2 x i64> [[A_COERCE:%.*]], i64 0)
197207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <8 x i64> @llvm.vector.extract.v8i64.nxv2i64(<vscale x 2 x i64> [[B_COERCE:%.*]], i64 0)
198207e5cccSFangrui Song // CHECK-NEXT:    [[OR:%.*]] = or <8 x i64> [[A]], [[B]]
199*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 2 x i64> @llvm.vector.insert.nxv2i64.v8i64(<vscale x 2 x i64> poison, <8 x i64> [[OR]], i64 0)
200207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 2 x i64> [[CAST_SCALABLE]]
201207e5cccSFangrui Song //
202207e5cccSFangrui Song fixed_int64_t or_i64(fixed_int64_t a, fixed_int64_t b) {
203207e5cccSFangrui Song   return a | b;
204207e5cccSFangrui Song }
205207e5cccSFangrui Song 
206207e5cccSFangrui Song // CHECK-LABEL: @or_u8(
207207e5cccSFangrui Song // CHECK-NEXT:  entry:
208207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <64 x i8> @llvm.vector.extract.v64i8.nxv16i8(<vscale x 16 x i8> [[A_COERCE:%.*]], i64 0)
209207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <64 x i8> @llvm.vector.extract.v64i8.nxv16i8(<vscale x 16 x i8> [[B_COERCE:%.*]], i64 0)
210207e5cccSFangrui Song // CHECK-NEXT:    [[OR:%.*]] = or <64 x i8> [[A]], [[B]]
211*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v64i8(<vscale x 16 x i8> poison, <64 x i8> [[OR]], i64 0)
212207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 16 x i8> [[CAST_SCALABLE]]
213207e5cccSFangrui Song //
214207e5cccSFangrui Song fixed_uint8_t or_u8(fixed_uint8_t a, fixed_uint8_t b) {
215207e5cccSFangrui Song   return a | b;
216207e5cccSFangrui Song }
217207e5cccSFangrui Song 
218207e5cccSFangrui Song // CHECK-LABEL: @or_u16(
219207e5cccSFangrui Song // CHECK-NEXT:  entry:
220207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <32 x i16> @llvm.vector.extract.v32i16.nxv8i16(<vscale x 8 x i16> [[A_COERCE:%.*]], i64 0)
221207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <32 x i16> @llvm.vector.extract.v32i16.nxv8i16(<vscale x 8 x i16> [[B_COERCE:%.*]], i64 0)
222207e5cccSFangrui Song // CHECK-NEXT:    [[OR:%.*]] = or <32 x i16> [[A]], [[B]]
223*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 8 x i16> @llvm.vector.insert.nxv8i16.v32i16(<vscale x 8 x i16> poison, <32 x i16> [[OR]], i64 0)
224207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 8 x i16> [[CAST_SCALABLE]]
225207e5cccSFangrui Song //
226207e5cccSFangrui Song fixed_uint16_t or_u16(fixed_uint16_t a, fixed_uint16_t b) {
227207e5cccSFangrui Song   return a | b;
228207e5cccSFangrui Song }
229207e5cccSFangrui Song 
230207e5cccSFangrui Song // CHECK-LABEL: @or_u32(
231207e5cccSFangrui Song // CHECK-NEXT:  entry:
232207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <16 x i32> @llvm.vector.extract.v16i32.nxv4i32(<vscale x 4 x i32> [[A_COERCE:%.*]], i64 0)
233207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <16 x i32> @llvm.vector.extract.v16i32.nxv4i32(<vscale x 4 x i32> [[B_COERCE:%.*]], i64 0)
234207e5cccSFangrui Song // CHECK-NEXT:    [[OR:%.*]] = or <16 x i32> [[A]], [[B]]
235*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 4 x i32> @llvm.vector.insert.nxv4i32.v16i32(<vscale x 4 x i32> poison, <16 x i32> [[OR]], i64 0)
236207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 4 x i32> [[CAST_SCALABLE]]
237207e5cccSFangrui Song //
238207e5cccSFangrui Song fixed_uint32_t or_u32(fixed_uint32_t a, fixed_uint32_t b) {
239207e5cccSFangrui Song   return a | b;
240207e5cccSFangrui Song }
241207e5cccSFangrui Song 
242207e5cccSFangrui Song // CHECK-LABEL: @or_u64(
243207e5cccSFangrui Song // CHECK-NEXT:  entry:
244207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <8 x i64> @llvm.vector.extract.v8i64.nxv2i64(<vscale x 2 x i64> [[A_COERCE:%.*]], i64 0)
245207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <8 x i64> @llvm.vector.extract.v8i64.nxv2i64(<vscale x 2 x i64> [[B_COERCE:%.*]], i64 0)
246207e5cccSFangrui Song // CHECK-NEXT:    [[OR:%.*]] = or <8 x i64> [[A]], [[B]]
247*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 2 x i64> @llvm.vector.insert.nxv2i64.v8i64(<vscale x 2 x i64> poison, <8 x i64> [[OR]], i64 0)
248207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 2 x i64> [[CAST_SCALABLE]]
249207e5cccSFangrui Song //
250207e5cccSFangrui Song fixed_uint64_t or_u64(fixed_uint64_t a, fixed_uint64_t b) {
251207e5cccSFangrui Song   return a | b;
252207e5cccSFangrui Song }
253207e5cccSFangrui Song 
254207e5cccSFangrui Song // XOR
255207e5cccSFangrui Song 
256207e5cccSFangrui Song // CHECK-LABEL: @xor_bool(
257207e5cccSFangrui Song // CHECK-NEXT:  entry:
258207e5cccSFangrui Song // CHECK-NEXT:    [[A_COERCE:%.*]] = bitcast <vscale x 16 x i1> [[TMP0:%.*]] to <vscale x 2 x i8>
259207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <8 x i8> @llvm.vector.extract.v8i8.nxv2i8(<vscale x 2 x i8> [[A_COERCE]], i64 0)
260207e5cccSFangrui Song // CHECK-NEXT:    [[B_COERCE:%.*]] = bitcast <vscale x 16 x i1> [[TMP1:%.*]] to <vscale x 2 x i8>
261207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <8 x i8> @llvm.vector.extract.v8i8.nxv2i8(<vscale x 2 x i8> [[B_COERCE]], i64 0)
262207e5cccSFangrui Song // CHECK-NEXT:    [[XOR:%.*]] = xor <8 x i8> [[A]], [[B]]
263*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 2 x i8> @llvm.vector.insert.nxv2i8.v8i8(<vscale x 2 x i8> poison, <8 x i8> [[XOR]], i64 0)
264207e5cccSFangrui Song // CHECK-NEXT:    [[TMP2:%.*]] = bitcast <vscale x 2 x i8> [[CAST_SCALABLE]] to <vscale x 16 x i1>
265207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 16 x i1> [[TMP2]]
266207e5cccSFangrui Song //
267207e5cccSFangrui Song fixed_bool_t xor_bool(fixed_bool_t a, fixed_bool_t b) {
268207e5cccSFangrui Song   return a ^ b;
269207e5cccSFangrui Song }
270207e5cccSFangrui Song 
271207e5cccSFangrui Song // CHECK-LABEL: @xor_i8(
272207e5cccSFangrui Song // CHECK-NEXT:  entry:
273207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <64 x i8> @llvm.vector.extract.v64i8.nxv16i8(<vscale x 16 x i8> [[A_COERCE:%.*]], i64 0)
274207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <64 x i8> @llvm.vector.extract.v64i8.nxv16i8(<vscale x 16 x i8> [[B_COERCE:%.*]], i64 0)
275207e5cccSFangrui Song // CHECK-NEXT:    [[XOR:%.*]] = xor <64 x i8> [[A]], [[B]]
276*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v64i8(<vscale x 16 x i8> poison, <64 x i8> [[XOR]], i64 0)
277207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 16 x i8> [[CAST_SCALABLE]]
278207e5cccSFangrui Song //
279207e5cccSFangrui Song fixed_int8_t xor_i8(fixed_int8_t a, fixed_int8_t b) {
280207e5cccSFangrui Song   return a ^ b;
281207e5cccSFangrui Song }
282207e5cccSFangrui Song 
283207e5cccSFangrui Song // CHECK-LABEL: @xor_i16(
284207e5cccSFangrui Song // CHECK-NEXT:  entry:
285207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <32 x i16> @llvm.vector.extract.v32i16.nxv8i16(<vscale x 8 x i16> [[A_COERCE:%.*]], i64 0)
286207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <32 x i16> @llvm.vector.extract.v32i16.nxv8i16(<vscale x 8 x i16> [[B_COERCE:%.*]], i64 0)
287207e5cccSFangrui Song // CHECK-NEXT:    [[XOR:%.*]] = xor <32 x i16> [[A]], [[B]]
288*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 8 x i16> @llvm.vector.insert.nxv8i16.v32i16(<vscale x 8 x i16> poison, <32 x i16> [[XOR]], i64 0)
289207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 8 x i16> [[CAST_SCALABLE]]
290207e5cccSFangrui Song //
291207e5cccSFangrui Song fixed_int16_t xor_i16(fixed_int16_t a, fixed_int16_t b) {
292207e5cccSFangrui Song   return a ^ b;
293207e5cccSFangrui Song }
294207e5cccSFangrui Song 
295207e5cccSFangrui Song // CHECK-LABEL: @xor_i32(
296207e5cccSFangrui Song // CHECK-NEXT:  entry:
297207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <16 x i32> @llvm.vector.extract.v16i32.nxv4i32(<vscale x 4 x i32> [[A_COERCE:%.*]], i64 0)
298207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <16 x i32> @llvm.vector.extract.v16i32.nxv4i32(<vscale x 4 x i32> [[B_COERCE:%.*]], i64 0)
299207e5cccSFangrui Song // CHECK-NEXT:    [[XOR:%.*]] = xor <16 x i32> [[A]], [[B]]
300*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 4 x i32> @llvm.vector.insert.nxv4i32.v16i32(<vscale x 4 x i32> poison, <16 x i32> [[XOR]], i64 0)
301207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 4 x i32> [[CAST_SCALABLE]]
302207e5cccSFangrui Song //
303207e5cccSFangrui Song fixed_int32_t xor_i32(fixed_int32_t a, fixed_int32_t b) {
304207e5cccSFangrui Song   return a ^ b;
305207e5cccSFangrui Song }
306207e5cccSFangrui Song 
307207e5cccSFangrui Song // CHECK-LABEL: @xor_i64(
308207e5cccSFangrui Song // CHECK-NEXT:  entry:
309207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <8 x i64> @llvm.vector.extract.v8i64.nxv2i64(<vscale x 2 x i64> [[A_COERCE:%.*]], i64 0)
310207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <8 x i64> @llvm.vector.extract.v8i64.nxv2i64(<vscale x 2 x i64> [[B_COERCE:%.*]], i64 0)
311207e5cccSFangrui Song // CHECK-NEXT:    [[XOR:%.*]] = xor <8 x i64> [[A]], [[B]]
312*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 2 x i64> @llvm.vector.insert.nxv2i64.v8i64(<vscale x 2 x i64> poison, <8 x i64> [[XOR]], i64 0)
313207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 2 x i64> [[CAST_SCALABLE]]
314207e5cccSFangrui Song //
315207e5cccSFangrui Song fixed_int64_t xor_i64(fixed_int64_t a, fixed_int64_t b) {
316207e5cccSFangrui Song   return a ^ b;
317207e5cccSFangrui Song }
318207e5cccSFangrui Song 
319207e5cccSFangrui Song // CHECK-LABEL: @xor_u8(
320207e5cccSFangrui Song // CHECK-NEXT:  entry:
321207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <64 x i8> @llvm.vector.extract.v64i8.nxv16i8(<vscale x 16 x i8> [[A_COERCE:%.*]], i64 0)
322207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <64 x i8> @llvm.vector.extract.v64i8.nxv16i8(<vscale x 16 x i8> [[B_COERCE:%.*]], i64 0)
323207e5cccSFangrui Song // CHECK-NEXT:    [[XOR:%.*]] = xor <64 x i8> [[A]], [[B]]
324*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v64i8(<vscale x 16 x i8> poison, <64 x i8> [[XOR]], i64 0)
325207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 16 x i8> [[CAST_SCALABLE]]
326207e5cccSFangrui Song //
327207e5cccSFangrui Song fixed_uint8_t xor_u8(fixed_uint8_t a, fixed_uint8_t b) {
328207e5cccSFangrui Song   return a ^ b;
329207e5cccSFangrui Song }
330207e5cccSFangrui Song 
331207e5cccSFangrui Song // CHECK-LABEL: @xor_u16(
332207e5cccSFangrui Song // CHECK-NEXT:  entry:
333207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <32 x i16> @llvm.vector.extract.v32i16.nxv8i16(<vscale x 8 x i16> [[A_COERCE:%.*]], i64 0)
334207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <32 x i16> @llvm.vector.extract.v32i16.nxv8i16(<vscale x 8 x i16> [[B_COERCE:%.*]], i64 0)
335207e5cccSFangrui Song // CHECK-NEXT:    [[XOR:%.*]] = xor <32 x i16> [[A]], [[B]]
336*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 8 x i16> @llvm.vector.insert.nxv8i16.v32i16(<vscale x 8 x i16> poison, <32 x i16> [[XOR]], i64 0)
337207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 8 x i16> [[CAST_SCALABLE]]
338207e5cccSFangrui Song //
339207e5cccSFangrui Song fixed_uint16_t xor_u16(fixed_uint16_t a, fixed_uint16_t b) {
340207e5cccSFangrui Song   return a ^ b;
341207e5cccSFangrui Song }
342207e5cccSFangrui Song 
343207e5cccSFangrui Song // CHECK-LABEL: @xor_u32(
344207e5cccSFangrui Song // CHECK-NEXT:  entry:
345207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <16 x i32> @llvm.vector.extract.v16i32.nxv4i32(<vscale x 4 x i32> [[A_COERCE:%.*]], i64 0)
346207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <16 x i32> @llvm.vector.extract.v16i32.nxv4i32(<vscale x 4 x i32> [[B_COERCE:%.*]], i64 0)
347207e5cccSFangrui Song // CHECK-NEXT:    [[XOR:%.*]] = xor <16 x i32> [[A]], [[B]]
348*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 4 x i32> @llvm.vector.insert.nxv4i32.v16i32(<vscale x 4 x i32> poison, <16 x i32> [[XOR]], i64 0)
349207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 4 x i32> [[CAST_SCALABLE]]
350207e5cccSFangrui Song //
351207e5cccSFangrui Song fixed_uint32_t xor_u32(fixed_uint32_t a, fixed_uint32_t b) {
352207e5cccSFangrui Song   return a ^ b;
353207e5cccSFangrui Song }
354207e5cccSFangrui Song 
355207e5cccSFangrui Song // CHECK-LABEL: @xor_u64(
356207e5cccSFangrui Song // CHECK-NEXT:  entry:
357207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <8 x i64> @llvm.vector.extract.v8i64.nxv2i64(<vscale x 2 x i64> [[A_COERCE:%.*]], i64 0)
358207e5cccSFangrui Song // CHECK-NEXT:    [[B:%.*]] = call <8 x i64> @llvm.vector.extract.v8i64.nxv2i64(<vscale x 2 x i64> [[B_COERCE:%.*]], i64 0)
359207e5cccSFangrui Song // CHECK-NEXT:    [[XOR:%.*]] = xor <8 x i64> [[A]], [[B]]
360*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 2 x i64> @llvm.vector.insert.nxv2i64.v8i64(<vscale x 2 x i64> poison, <8 x i64> [[XOR]], i64 0)
361207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 2 x i64> [[CAST_SCALABLE]]
362207e5cccSFangrui Song //
363207e5cccSFangrui Song fixed_uint64_t xor_u64(fixed_uint64_t a, fixed_uint64_t b) {
364207e5cccSFangrui Song   return a ^ b;
365207e5cccSFangrui Song }
366207e5cccSFangrui Song 
367207e5cccSFangrui Song // NEG
368207e5cccSFangrui Song 
369207e5cccSFangrui Song // CHECK-LABEL: @neg_bool(
370207e5cccSFangrui Song // CHECK-NEXT:  entry:
371207e5cccSFangrui Song // CHECK-NEXT:    [[A_COERCE:%.*]] = bitcast <vscale x 16 x i1> [[TMP0:%.*]] to <vscale x 2 x i8>
372207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <8 x i8> @llvm.vector.extract.v8i8.nxv2i8(<vscale x 2 x i8> [[A_COERCE]], i64 0)
373207e5cccSFangrui Song // CHECK-NEXT:    [[NOT:%.*]] = xor <8 x i8> [[A]], splat (i8 -1)
374*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 2 x i8> @llvm.vector.insert.nxv2i8.v8i8(<vscale x 2 x i8> poison, <8 x i8> [[NOT]], i64 0)
375207e5cccSFangrui Song // CHECK-NEXT:    [[TMP1:%.*]] = bitcast <vscale x 2 x i8> [[CAST_SCALABLE]] to <vscale x 16 x i1>
376207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 16 x i1> [[TMP1]]
377207e5cccSFangrui Song //
378207e5cccSFangrui Song fixed_bool_t neg_bool(fixed_bool_t a) {
379207e5cccSFangrui Song   return ~a;
380207e5cccSFangrui Song }
381207e5cccSFangrui Song 
382207e5cccSFangrui Song // CHECK-LABEL: @neg_i8(
383207e5cccSFangrui Song // CHECK-NEXT:  entry:
384207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <64 x i8> @llvm.vector.extract.v64i8.nxv16i8(<vscale x 16 x i8> [[A_COERCE:%.*]], i64 0)
385207e5cccSFangrui Song // CHECK-NEXT:    [[NOT:%.*]] = xor <64 x i8> [[A]], splat (i8 -1)
386*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v64i8(<vscale x 16 x i8> poison, <64 x i8> [[NOT]], i64 0)
387207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 16 x i8> [[CAST_SCALABLE]]
388207e5cccSFangrui Song //
389207e5cccSFangrui Song fixed_int8_t neg_i8(fixed_int8_t a) {
390207e5cccSFangrui Song   return ~a;
391207e5cccSFangrui Song }
392207e5cccSFangrui Song 
393207e5cccSFangrui Song // CHECK-LABEL: @neg_i16(
394207e5cccSFangrui Song // CHECK-NEXT:  entry:
395207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <32 x i16> @llvm.vector.extract.v32i16.nxv8i16(<vscale x 8 x i16> [[A_COERCE:%.*]], i64 0)
396207e5cccSFangrui Song // CHECK-NEXT:    [[NOT:%.*]] = xor <32 x i16> [[A]], splat (i16 -1)
397*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 8 x i16> @llvm.vector.insert.nxv8i16.v32i16(<vscale x 8 x i16> poison, <32 x i16> [[NOT]], i64 0)
398207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 8 x i16> [[CAST_SCALABLE]]
399207e5cccSFangrui Song //
400207e5cccSFangrui Song fixed_int16_t neg_i16(fixed_int16_t a) {
401207e5cccSFangrui Song   return ~a;
402207e5cccSFangrui Song }
403207e5cccSFangrui Song 
404207e5cccSFangrui Song // CHECK-LABEL: @neg_i32(
405207e5cccSFangrui Song // CHECK-NEXT:  entry:
406207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <16 x i32> @llvm.vector.extract.v16i32.nxv4i32(<vscale x 4 x i32> [[A_COERCE:%.*]], i64 0)
407207e5cccSFangrui Song // CHECK-NEXT:    [[NOT:%.*]] = xor <16 x i32> [[A]], splat (i32 -1)
408*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 4 x i32> @llvm.vector.insert.nxv4i32.v16i32(<vscale x 4 x i32> poison, <16 x i32> [[NOT]], i64 0)
409207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 4 x i32> [[CAST_SCALABLE]]
410207e5cccSFangrui Song //
411207e5cccSFangrui Song fixed_int32_t neg_i32(fixed_int32_t a) {
412207e5cccSFangrui Song   return ~a;
413207e5cccSFangrui Song }
414207e5cccSFangrui Song 
415207e5cccSFangrui Song // CHECK-LABEL: @neg_i64(
416207e5cccSFangrui Song // CHECK-NEXT:  entry:
417207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <8 x i64> @llvm.vector.extract.v8i64.nxv2i64(<vscale x 2 x i64> [[A_COERCE:%.*]], i64 0)
418207e5cccSFangrui Song // CHECK-NEXT:    [[NOT:%.*]] = xor <8 x i64> [[A]], splat (i64 -1)
419*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 2 x i64> @llvm.vector.insert.nxv2i64.v8i64(<vscale x 2 x i64> poison, <8 x i64> [[NOT]], i64 0)
420207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 2 x i64> [[CAST_SCALABLE]]
421207e5cccSFangrui Song //
422207e5cccSFangrui Song fixed_int64_t neg_i64(fixed_int64_t a) {
423207e5cccSFangrui Song   return ~a;
424207e5cccSFangrui Song }
425207e5cccSFangrui Song 
426207e5cccSFangrui Song // CHECK-LABEL: @neg_u8(
427207e5cccSFangrui Song // CHECK-NEXT:  entry:
428207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <64 x i8> @llvm.vector.extract.v64i8.nxv16i8(<vscale x 16 x i8> [[A_COERCE:%.*]], i64 0)
429207e5cccSFangrui Song // CHECK-NEXT:    [[NOT:%.*]] = xor <64 x i8> [[A]], splat (i8 -1)
430*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v64i8(<vscale x 16 x i8> poison, <64 x i8> [[NOT]], i64 0)
431207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 16 x i8> [[CAST_SCALABLE]]
432207e5cccSFangrui Song //
433207e5cccSFangrui Song fixed_uint8_t neg_u8(fixed_uint8_t a) {
434207e5cccSFangrui Song   return ~a;
435207e5cccSFangrui Song }
436207e5cccSFangrui Song 
437207e5cccSFangrui Song // CHECK-LABEL: @neg_u16(
438207e5cccSFangrui Song // CHECK-NEXT:  entry:
439207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <32 x i16> @llvm.vector.extract.v32i16.nxv8i16(<vscale x 8 x i16> [[A_COERCE:%.*]], i64 0)
440207e5cccSFangrui Song // CHECK-NEXT:    [[NOT:%.*]] = xor <32 x i16> [[A]], splat (i16 -1)
441*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 8 x i16> @llvm.vector.insert.nxv8i16.v32i16(<vscale x 8 x i16> poison, <32 x i16> [[NOT]], i64 0)
442207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 8 x i16> [[CAST_SCALABLE]]
443207e5cccSFangrui Song //
444207e5cccSFangrui Song fixed_uint16_t neg_u16(fixed_uint16_t a) {
445207e5cccSFangrui Song   return ~a;
446207e5cccSFangrui Song }
447207e5cccSFangrui Song 
448207e5cccSFangrui Song // CHECK-LABEL: @neg_u32(
449207e5cccSFangrui Song // CHECK-NEXT:  entry:
450207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <16 x i32> @llvm.vector.extract.v16i32.nxv4i32(<vscale x 4 x i32> [[A_COERCE:%.*]], i64 0)
451207e5cccSFangrui Song // CHECK-NEXT:    [[NOT:%.*]] = xor <16 x i32> [[A]], splat (i32 -1)
452*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 4 x i32> @llvm.vector.insert.nxv4i32.v16i32(<vscale x 4 x i32> poison, <16 x i32> [[NOT]], i64 0)
453207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 4 x i32> [[CAST_SCALABLE]]
454207e5cccSFangrui Song //
455207e5cccSFangrui Song fixed_uint32_t neg_u32(fixed_uint32_t a) {
456207e5cccSFangrui Song   return ~a;
457207e5cccSFangrui Song }
458207e5cccSFangrui Song 
459207e5cccSFangrui Song // CHECK-LABEL: @neg_u64(
460207e5cccSFangrui Song // CHECK-NEXT:  entry:
461207e5cccSFangrui Song // CHECK-NEXT:    [[A:%.*]] = call <8 x i64> @llvm.vector.extract.v8i64.nxv2i64(<vscale x 2 x i64> [[A_COERCE:%.*]], i64 0)
462207e5cccSFangrui Song // CHECK-NEXT:    [[NOT:%.*]] = xor <8 x i64> [[A]], splat (i64 -1)
463*98e747baSPedro Lobo // CHECK-NEXT:    [[CAST_SCALABLE:%.*]] = call <vscale x 2 x i64> @llvm.vector.insert.nxv2i64.v8i64(<vscale x 2 x i64> poison, <8 x i64> [[NOT]], i64 0)
464207e5cccSFangrui Song // CHECK-NEXT:    ret <vscale x 2 x i64> [[CAST_SCALABLE]]
465207e5cccSFangrui Song //
466207e5cccSFangrui Song fixed_uint64_t neg_u64(fixed_uint64_t a) {
467207e5cccSFangrui Song   return ~a;
468207e5cccSFangrui Song }
469