Skip to content

Commit 8dea981

Browse files
author
Christophe Lyon
committed
arm: [MVE intrinsics] rework sqshll srshrl uqshll urshrl
Implement sqshll, srshrl, uqshll and urshrl using the new MVE builtins framework. gcc/ChangeLog: * config/arm/arm-mve-builtins-base.cc (enum which_scalar_shift): Add ss_SQSHLL, ss_SRSHRL, ss_UQSHLL, ss_URSHRL. (mve_function_scalar_shift): Add support for ss_SQSHLL, ss_SRSHRL, ss_UQSHLL, ss_URSHRL. * config/arm/arm-mve-builtins-base.def (sqshll, srshrl, uqshll) (urshrl): New. * config/arm/arm-mve-builtins-base.h (sqshll, srshrl, uqshll) (urshrl): New. * config/arm/arm-mve-builtins-shapes.cc (scalar_s64_shift_imm) (scalar_u64_shift_imm): New. * config/arm/arm-mve-builtins-shapes.h (scalar_s64_shift_imm) (scalar_u64_shift_imm): New. * config/arm/arm_mve.h (sqshll): Delete. (srshrl): Delete. (uqshll): Delete. (urshrl): Delete. (__arm_uqshll): Delete. (__arm_urshrl): Delete. (__arm_srshrl): Delete. (__arm_sqshll): Delete. gcc/testsuite/ChangeLog: * gcc.target/arm/mve/intrinsics/sqshll_check_shift.c: New test. * gcc.target/arm/mve/intrinsics/srshrl_check_shift.c: New test. * gcc.target/arm/mve/intrinsics/uqshll_check_shift.c: New test. * gcc.target/arm/mve/intrinsics/urshrl_check_shift.c: New test.
1 parent 859c3ce commit 8dea981

File tree

10 files changed

+176
-32
lines changed

10 files changed

+176
-32
lines changed

gcc/config/arm/arm-mve-builtins-base.cc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,8 +1174,12 @@ enum which_scalar_shift {
11741174
ss_LSLL,
11751175
ss_SQRSHRL,
11761176
ss_SQRSHRL_SAT48,
1177+
ss_SQSHLL,
1178+
ss_SRSHRL,
11771179
ss_UQRSHLL,
11781180
ss_UQRSHLL_SAT48,
1181+
ss_UQSHLL,
1182+
ss_URSHRL
11791183
};
11801184

11811185
class mve_function_scalar_shift : public function_base
@@ -1213,6 +1217,14 @@ class mve_function_scalar_shift : public function_base
12131217
code = code_for_mve_sqrshrl_sat_di (SQRSHRL_48);
12141218
break;
12151219

1220+
case ss_SQSHLL:
1221+
code = CODE_FOR_mve_sqshll_di;
1222+
break;
1223+
1224+
case ss_SRSHRL:
1225+
code = CODE_FOR_mve_srshrl_di;
1226+
break;
1227+
12161228
case ss_UQRSHLL:
12171229
code = code_for_mve_uqrshll_sat_di (UQRSHLL_64);
12181230
break;
@@ -1221,6 +1233,14 @@ class mve_function_scalar_shift : public function_base
12211233
code = code_for_mve_uqrshll_sat_di (UQRSHLL_48);
12221234
break;
12231235

1236+
case ss_UQSHLL:
1237+
code = CODE_FOR_mve_uqshll_di;
1238+
break;
1239+
1240+
case ss_URSHRL:
1241+
code = CODE_FOR_mve_urshrl_di;
1242+
break;
1243+
12241244
default:
12251245
gcc_unreachable ();
12261246
}
@@ -1419,8 +1439,12 @@ FUNCTION (asrl, mve_function_scalar_shift, (ss_ASRL))
14191439
FUNCTION (lsll, mve_function_scalar_shift, (ss_LSLL))
14201440
FUNCTION (sqrshrl, mve_function_scalar_shift, (ss_SQRSHRL))
14211441
FUNCTION (sqrshrl_sat48, mve_function_scalar_shift, (ss_SQRSHRL_SAT48))
1442+
FUNCTION (sqshll, mve_function_scalar_shift, (ss_SQSHLL))
1443+
FUNCTION (srshrl, mve_function_scalar_shift, (ss_SRSHRL))
14221444
FUNCTION (uqrshll, mve_function_scalar_shift, (ss_UQRSHLL))
14231445
FUNCTION (uqrshll_sat48, mve_function_scalar_shift, (ss_UQRSHLL_SAT48))
1446+
FUNCTION (uqshll, mve_function_scalar_shift, (ss_UQSHLL))
1447+
FUNCTION (urshrl, mve_function_scalar_shift, (ss_URSHRL))
14241448
FUNCTION_PRED_P_S_U (vabavq, VABAVQ)
14251449
FUNCTION_WITHOUT_N (vabdq, VABDQ)
14261450
FUNCTION (vabsq, unspec_based_mve_function_exact_insn, (ABS, ABS, ABS, -1, -1, -1, VABSQ_M_S, -1, VABSQ_M_F, -1, -1, -1))

gcc/config/arm/arm-mve-builtins-base.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ DEF_MVE_FUNCTION (asrl, scalar_s64_shift, none, none)
2222
DEF_MVE_FUNCTION (lsll, scalar_u64_shift, none, none)
2323
DEF_MVE_FUNCTION (sqrshrl, scalar_s64_shift, none, none)
2424
DEF_MVE_FUNCTION (sqrshrl_sat48, scalar_s64_shift, none, none)
25+
DEF_MVE_FUNCTION (sqshll, scalar_s64_shift_imm, none, none)
26+
DEF_MVE_FUNCTION (srshrl, scalar_s64_shift_imm, none, none)
2527
DEF_MVE_FUNCTION (uqrshll, scalar_u64_shift, none, none)
2628
DEF_MVE_FUNCTION (uqrshll_sat48, scalar_u64_shift, none, none)
29+
DEF_MVE_FUNCTION (uqshll, scalar_u64_shift_imm, none, none)
30+
DEF_MVE_FUNCTION (urshrl, scalar_u64_shift_imm, none, none)
2731
DEF_MVE_FUNCTION (vabavq, binary_acca_int32, all_integer, p_or_none)
2832
DEF_MVE_FUNCTION (vabdq, binary, all_integer, mx_or_none)
2933
DEF_MVE_FUNCTION (vabsq, unary, all_signed, mx_or_none)

gcc/config/arm/arm-mve-builtins-base.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ extern const function_base *const asrl;
2727
extern const function_base *const lsll;
2828
extern const function_base *const sqrshrl;
2929
extern const function_base *const sqrshrl_sat48;
30+
extern const function_base *const sqshll;
31+
extern const function_base *const srshrl;
3032
extern const function_base *const uqrshll;
3133
extern const function_base *const uqrshll_sat48;
34+
extern const function_base *const uqshll;
35+
extern const function_base *const urshrl;
3236
extern const function_base *const vabavq;
3337
extern const function_base *const vabdq;
3438
extern const function_base *const vabsq;

gcc/config/arm/arm-mve-builtins-shapes.cc

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,6 +1697,29 @@ struct scalar_s64_shift_def : public nonoverloaded_base
16971697
};
16981698
SHAPE (scalar_s64_shift)
16991699

1700+
/* int64_t foo(int64_t, const int)
1701+
1702+
Check that 'shift' is in the [1,32] range.
1703+
1704+
Example: sqshll.
1705+
int64_t [__arm_]sqshll(int64_t value, const int shift) */
1706+
struct scalar_s64_shift_imm_def : public nonoverloaded_base
1707+
{
1708+
void
1709+
build (function_builder &b, const function_group_info &group,
1710+
bool preserve_user_namespace) const override
1711+
{
1712+
build_all (b, "ss64,ss64,su64", group, MODE_none, preserve_user_namespace);
1713+
}
1714+
1715+
bool
1716+
check (function_checker &c) const override
1717+
{
1718+
return c.require_immediate_range (1, 1, 32);
1719+
}
1720+
};
1721+
SHAPE (scalar_s64_shift_imm)
1722+
17001723
/* uint64_t foo(uint64_t, int32_t)
17011724
17021725
Example: lsll.
@@ -1712,6 +1735,29 @@ struct scalar_u64_shift_def : public nonoverloaded_base
17121735
};
17131736
SHAPE (scalar_u64_shift)
17141737

1738+
/* uint64_t foo(uint64_t, const int)
1739+
1740+
Check that 'shift' is in the [1,32] range.
1741+
1742+
Example: uqshll.
1743+
uint64_t [__arm_]uqshll(uint64_t value, const int shift) */
1744+
struct scalar_u64_shift_imm_def : public nonoverloaded_base
1745+
{
1746+
void
1747+
build (function_builder &b, const function_group_info &group,
1748+
bool preserve_user_namespace) const override
1749+
{
1750+
build_all (b, "su64,su64,su64", group, MODE_none, preserve_user_namespace);
1751+
}
1752+
1753+
bool
1754+
check (function_checker &c) const override
1755+
{
1756+
return c.require_immediate_range (1, 1, 32);
1757+
}
1758+
};
1759+
SHAPE (scalar_u64_shift_imm)
1760+
17151761
/* void vfoo[_t0](<X>_t *, <T0>[xN]_t)
17161762
17171763
where <X> might be tied to <t0> (for non-truncating stores) or might

gcc/config/arm/arm-mve-builtins-shapes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ namespace arm_mve
6767
extern const function_shape *const load_gather_base;
6868
extern const function_shape *const mvn;
6969
extern const function_shape *const scalar_s64_shift;
70+
extern const function_shape *const scalar_s64_shift_imm;
7071
extern const function_shape *const scalar_u64_shift;
72+
extern const function_shape *const scalar_u64_shift_imm;
7173
extern const function_shape *const store;
7274
extern const function_shape *const store_scatter_base;
7375
extern const function_shape *const store_scatter_offset;

gcc/config/arm/arm_mve.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,10 @@
8282
#define vgetq_lane_u64(__a, __idx) __arm_vgetq_lane_u64(__a, __idx)
8383
#define sqrshr(__p0, __p1) __arm_sqrshr(__p0, __p1)
8484
#define sqshl(__p0, __p1) __arm_sqshl(__p0, __p1)
85-
#define sqshll(__p0, __p1) __arm_sqshll(__p0, __p1)
8685
#define srshr(__p0, __p1) __arm_srshr(__p0, __p1)
87-
#define srshrl(__p0, __p1) __arm_srshrl(__p0, __p1)
8886
#define uqrshl(__p0, __p1) __arm_uqrshl(__p0, __p1)
8987
#define uqshl(__p0, __p1) __arm_uqshl(__p0, __p1)
90-
#define uqshll(__p0, __p1) __arm_uqshll(__p0, __p1)
9188
#define urshr(__p0, __p1) __arm_urshr(__p0, __p1)
92-
#define urshrl(__p0, __p1) __arm_urshrl(__p0, __p1)
9389
#endif
9490

9591
/* For big-endian, GCC's vector indices are reversed within each 64 bits
@@ -240,34 +236,6 @@ __arm_vgetq_lane_u64 (uint64x2_t __a, const int __idx)
240236
return __a[__ARM_LANEQ(__a,__idx)];
241237
}
242238

243-
__extension__ extern __inline uint64_t
244-
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
245-
__arm_uqshll (uint64_t value, const int shift)
246-
{
247-
return __builtin_mve_uqshll_di (value, shift);
248-
}
249-
250-
__extension__ extern __inline uint64_t
251-
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
252-
__arm_urshrl (uint64_t value, const int shift)
253-
{
254-
return __builtin_mve_urshrl_di (value, shift);
255-
}
256-
257-
__extension__ extern __inline int64_t
258-
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
259-
__arm_srshrl (int64_t value, const int shift)
260-
{
261-
return __builtin_mve_srshrl_di (value, shift);
262-
}
263-
264-
__extension__ extern __inline int64_t
265-
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
266-
__arm_sqshll (int64_t value, const int shift)
267-
{
268-
return __builtin_mve_sqshll_di (value, shift);
269-
}
270-
271239
__extension__ extern __inline uint32_t
272240
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
273241
__arm_uqrshl (uint32_t value, int32_t shift)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* { dg-require-effective-target arm_v8_1m_mve_ok } */
2+
/* { dg-add-options arm_v8_1m_mve } */
3+
4+
#include "arm_mve.h"
5+
6+
#ifdef __cplusplus
7+
extern "C" {
8+
#endif
9+
10+
int64_t
11+
foo (int64_t value)
12+
{
13+
return sqshll (value, 33); /* { dg-error {passing 33 to argument 2 of 'sqshll', which expects a value in the range \[1, 32\]} } */
14+
}
15+
16+
int64_t
17+
foo1 (int64_t value)
18+
{
19+
return sqshll (value, -1); /* { dg-error {passing -1 to argument 2 of 'sqshll', which expects a value in the range \[1, 32\]} } */
20+
}
21+
22+
#ifdef __cplusplus
23+
}
24+
#endif
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* { dg-require-effective-target arm_v8_1m_mve_ok } */
2+
/* { dg-add-options arm_v8_1m_mve } */
3+
4+
#include "arm_mve.h"
5+
6+
#ifdef __cplusplus
7+
extern "C" {
8+
#endif
9+
10+
int64_t
11+
foo (int64_t value)
12+
{
13+
return srshrl (value, 33); /* { dg-error {passing 33 to argument 2 of 'srshrl', which expects a value in the range \[1, 32\]} } */
14+
}
15+
16+
int64_t
17+
foo1 (int64_t value)
18+
{
19+
return srshrl (value, -1); /* { dg-error {passing -1 to argument 2 of 'srshrl', which expects a value in the range \[1, 32\]} } */
20+
}
21+
22+
#ifdef __cplusplus
23+
}
24+
#endif
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* { dg-require-effective-target arm_v8_1m_mve_ok } */
2+
/* { dg-add-options arm_v8_1m_mve } */
3+
4+
#include "arm_mve.h"
5+
6+
#ifdef __cplusplus
7+
extern "C" {
8+
#endif
9+
10+
uint64_t
11+
foo (uint64_t value)
12+
{
13+
return uqshll (value, 33); /* { dg-error {passing 33 to argument 2 of 'uqshll', which expects a value in the range \[1, 32\]} } */
14+
}
15+
16+
uint64_t
17+
foo1 (uint64_t value)
18+
{
19+
return uqshll (value, -1); /* { dg-error {passing -1 to argument 2 of 'uqshll', which expects a value in the range \[1, 32\]} } */
20+
}
21+
22+
#ifdef __cplusplus
23+
}
24+
#endif
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* { dg-require-effective-target arm_v8_1m_mve_ok } */
2+
/* { dg-add-options arm_v8_1m_mve } */
3+
4+
#include "arm_mve.h"
5+
6+
#ifdef __cplusplus
7+
extern "C" {
8+
#endif
9+
10+
uint64_t
11+
foo (uint64_t value)
12+
{
13+
return urshrl (value, 33); /* { dg-error {passing 33 to argument 2 of 'urshrl', which expects a value in the range \[1, 32\]} } */
14+
}
15+
16+
uint64_t
17+
foo1 (uint64_t value)
18+
{
19+
return urshrl (value, -1); /* { dg-error {passing -1 to argument 2 of 'urshrl', which expects a value in the range \[1, 32\]} } */
20+
}
21+
22+
#ifdef __cplusplus
23+
}
24+
#endif

0 commit comments

Comments
 (0)