Skip to content

Commit c577201

Browse files
committed
[SveEmitter] Add builtins for bitcount operations
This patch adds builtins for svcls, svclz and svcnt. For merging (_m), zeroing (_z) and don't-care (_x) predication.
1 parent ef06016 commit c577201

File tree

4 files changed

+652
-0
lines changed

4 files changed

+652
-0
lines changed

clang/include/clang/Basic/arm_sve.td

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,19 @@ def SVWHILELS_U64 : SInst<"svwhilele_{d}[_{1}]", "Pnn", "PUcPUsPUiPUl", MergeNon
702702
def SVWHILELT_S32 : SInst<"svwhilelt_{d}[_{1}]", "Pkk", "PcPsPiPl", MergeNone, "aarch64_sve_whilelt", [IsOverloadWhile]>;
703703
def SVWHILELT_S64 : SInst<"svwhilelt_{d}[_{1}]", "Pll", "PcPsPiPl", MergeNone, "aarch64_sve_whilelt", [IsOverloadWhile]>;
704704

705+
////////////////////////////////////////////////////////////////////////////////
706+
// Counting bit
707+
708+
multiclass SInstCLS<string name, string types, string intrinsic, list<FlagType> flags=[]> {
709+
def _M : SInst<name # "[_{d}]", "uuPd", types, MergeOp1, intrinsic, flags>;
710+
def _X : SInst<name # "[_{d}]", "uPd", types, MergeAnyExp, intrinsic, flags>;
711+
def _Z : SInst<name # "[_{d}]", "uPd", types, MergeZeroExp, intrinsic, flags>;
712+
}
713+
714+
defm SVCLS : SInstCLS<"svcls", "csil", "aarch64_sve_cls">;
715+
defm SVCLZ : SInstCLS<"svclz", "csilUcUsUiUl", "aarch64_sve_clz">;
716+
defm SVCNT : SInstCLS<"svcnt", "csilUcUsUiUlhfd", "aarch64_sve_cnt">;
717+
705718
////////////////////////////////////////////////////////////////////////////////
706719
// Floating-point arithmetic
707720

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
2+
// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
3+
4+
#include <arm_sve.h>
5+
6+
#ifdef SVE_OVERLOADED_FORMS
7+
// A simple used,unused... macro, long enough to represent any SVE builtin.
8+
#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
9+
#else
10+
#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
11+
#endif
12+
13+
svuint8_t test_svcls_s8_z(svbool_t pg, svint8_t op)
14+
{
15+
// CHECK-LABEL: test_svcls_s8_z
16+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.cls.nxv16i8(<vscale x 16 x i8> zeroinitializer, <vscale x 16 x i1> %pg, <vscale x 16 x i8> %op)
17+
// CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
18+
return SVE_ACLE_FUNC(svcls,_s8,_z,)(pg, op);
19+
}
20+
21+
svuint16_t test_svcls_s16_z(svbool_t pg, svint16_t op)
22+
{
23+
// CHECK-LABEL: test_svcls_s16_z
24+
// CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
25+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.cls.nxv8i16(<vscale x 8 x i16> zeroinitializer, <vscale x 8 x i1> %[[PG]], <vscale x 8 x i16> %op)
26+
// CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
27+
return SVE_ACLE_FUNC(svcls,_s16,_z,)(pg, op);
28+
}
29+
30+
svuint32_t test_svcls_s32_z(svbool_t pg, svint32_t op)
31+
{
32+
// CHECK-LABEL: test_svcls_s32_z
33+
// CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
34+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.cls.nxv4i32(<vscale x 4 x i32> zeroinitializer, <vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %op)
35+
// CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
36+
return SVE_ACLE_FUNC(svcls,_s32,_z,)(pg, op);
37+
}
38+
39+
svuint64_t test_svcls_s64_z(svbool_t pg, svint64_t op)
40+
{
41+
// CHECK-LABEL: test_svcls_s64_z
42+
// CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
43+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.cls.nxv2i64(<vscale x 2 x i64> zeroinitializer, <vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %op)
44+
// CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
45+
return SVE_ACLE_FUNC(svcls,_s64,_z,)(pg, op);
46+
}
47+
48+
svuint8_t test_svcls_s8_m(svuint8_t inactive, svbool_t pg, svint8_t op)
49+
{
50+
// CHECK-LABEL: test_svcls_s8_m
51+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.cls.nxv16i8(<vscale x 16 x i8> %inactive, <vscale x 16 x i1> %pg, <vscale x 16 x i8> %op)
52+
// CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
53+
return SVE_ACLE_FUNC(svcls,_s8,_m,)(inactive, pg, op);
54+
}
55+
56+
svuint16_t test_svcls_s16_m(svuint16_t inactive, svbool_t pg, svint16_t op)
57+
{
58+
// CHECK-LABEL: test_svcls_s16_m
59+
// CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
60+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.cls.nxv8i16(<vscale x 8 x i16> %inactive, <vscale x 8 x i1> %[[PG]], <vscale x 8 x i16> %op)
61+
// CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
62+
return SVE_ACLE_FUNC(svcls,_s16,_m,)(inactive, pg, op);
63+
}
64+
65+
svuint32_t test_svcls_s32_m(svuint32_t inactive, svbool_t pg, svint32_t op)
66+
{
67+
// CHECK-LABEL: test_svcls_s32_m
68+
// CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
69+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.cls.nxv4i32(<vscale x 4 x i32> %inactive, <vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %op)
70+
// CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
71+
return SVE_ACLE_FUNC(svcls,_s32,_m,)(inactive, pg, op);
72+
}
73+
74+
svuint64_t test_svcls_s64_m(svuint64_t inactive, svbool_t pg, svint64_t op)
75+
{
76+
// CHECK-LABEL: test_svcls_s64_m
77+
// CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
78+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.cls.nxv2i64(<vscale x 2 x i64> %inactive, <vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %op)
79+
// CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
80+
return SVE_ACLE_FUNC(svcls,_s64,_m,)(inactive, pg, op);
81+
}
82+
83+
svuint8_t test_svcls_s8_x(svbool_t pg, svint8_t op)
84+
{
85+
// CHECK-LABEL: test_svcls_s8_x
86+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.cls.nxv16i8(<vscale x 16 x i8> undef, <vscale x 16 x i1> %pg, <vscale x 16 x i8> %op)
87+
// CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
88+
return SVE_ACLE_FUNC(svcls,_s8,_x,)(pg, op);
89+
}
90+
91+
svuint16_t test_svcls_s16_x(svbool_t pg, svint16_t op)
92+
{
93+
// CHECK-LABEL: test_svcls_s16_x
94+
// CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
95+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.cls.nxv8i16(<vscale x 8 x i16> undef, <vscale x 8 x i1> %[[PG]], <vscale x 8 x i16> %op)
96+
// CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
97+
return SVE_ACLE_FUNC(svcls,_s16,_x,)(pg, op);
98+
}
99+
100+
svuint32_t test_svcls_s32_x(svbool_t pg, svint32_t op)
101+
{
102+
// CHECK-LABEL: test_svcls_s32_x
103+
// CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
104+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.cls.nxv4i32(<vscale x 4 x i32> undef, <vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %op)
105+
// CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
106+
return SVE_ACLE_FUNC(svcls,_s32,_x,)(pg, op);
107+
}
108+
109+
svuint64_t test_svcls_s64_x(svbool_t pg, svint64_t op)
110+
{
111+
// CHECK-LABEL: test_svcls_s64_x
112+
// CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
113+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.cls.nxv2i64(<vscale x 2 x i64> undef, <vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %op)
114+
// CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
115+
return SVE_ACLE_FUNC(svcls,_s64,_x,)(pg, op);
116+
}
Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
2+
// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
3+
4+
#include <arm_sve.h>
5+
6+
#ifdef SVE_OVERLOADED_FORMS
7+
// A simple used,unused... macro, long enough to represent any SVE builtin.
8+
#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
9+
#else
10+
#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
11+
#endif
12+
13+
svuint8_t test_svclz_s8_z(svbool_t pg, svint8_t op)
14+
{
15+
// CHECK-LABEL: test_svclz_s8_z
16+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.clz.nxv16i8(<vscale x 16 x i8> zeroinitializer, <vscale x 16 x i1> %pg, <vscale x 16 x i8> %op)
17+
// CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
18+
return SVE_ACLE_FUNC(svclz,_s8,_z,)(pg, op);
19+
}
20+
21+
svuint16_t test_svclz_s16_z(svbool_t pg, svint16_t op)
22+
{
23+
// CHECK-LABEL: test_svclz_s16_z
24+
// CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
25+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.clz.nxv8i16(<vscale x 8 x i16> zeroinitializer, <vscale x 8 x i1> %[[PG]], <vscale x 8 x i16> %op)
26+
// CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
27+
return SVE_ACLE_FUNC(svclz,_s16,_z,)(pg, op);
28+
}
29+
30+
svuint32_t test_svclz_s32_z(svbool_t pg, svint32_t op)
31+
{
32+
// CHECK-LABEL: test_svclz_s32_z
33+
// CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
34+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.clz.nxv4i32(<vscale x 4 x i32> zeroinitializer, <vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %op)
35+
// CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
36+
return SVE_ACLE_FUNC(svclz,_s32,_z,)(pg, op);
37+
}
38+
39+
svuint64_t test_svclz_s64_z(svbool_t pg, svint64_t op)
40+
{
41+
// CHECK-LABEL: test_svclz_s64_z
42+
// CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
43+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.clz.nxv2i64(<vscale x 2 x i64> zeroinitializer, <vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %op)
44+
// CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
45+
return SVE_ACLE_FUNC(svclz,_s64,_z,)(pg, op);
46+
}
47+
48+
svuint8_t test_svclz_u8_z(svbool_t pg, svuint8_t op)
49+
{
50+
// CHECK-LABEL: test_svclz_u8_z
51+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.clz.nxv16i8(<vscale x 16 x i8> zeroinitializer, <vscale x 16 x i1> %pg, <vscale x 16 x i8> %op)
52+
// CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
53+
return SVE_ACLE_FUNC(svclz,_u8,_z,)(pg, op);
54+
}
55+
56+
svuint16_t test_svclz_u16_z(svbool_t pg, svuint16_t op)
57+
{
58+
// CHECK-LABEL: test_svclz_u16_z
59+
// CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
60+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.clz.nxv8i16(<vscale x 8 x i16> zeroinitializer, <vscale x 8 x i1> %[[PG]], <vscale x 8 x i16> %op)
61+
// CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
62+
return SVE_ACLE_FUNC(svclz,_u16,_z,)(pg, op);
63+
}
64+
65+
svuint32_t test_svclz_u32_z(svbool_t pg, svuint32_t op)
66+
{
67+
// CHECK-LABEL: test_svclz_u32_z
68+
// CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
69+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.clz.nxv4i32(<vscale x 4 x i32> zeroinitializer, <vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %op)
70+
// CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
71+
return SVE_ACLE_FUNC(svclz,_u32,_z,)(pg, op);
72+
}
73+
74+
svuint64_t test_svclz_u64_z(svbool_t pg, svuint64_t op)
75+
{
76+
// CHECK-LABEL: test_svclz_u64_z
77+
// CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
78+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.clz.nxv2i64(<vscale x 2 x i64> zeroinitializer, <vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %op)
79+
// CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
80+
return SVE_ACLE_FUNC(svclz,_u64,_z,)(pg, op);
81+
}
82+
83+
svuint8_t test_svclz_s8_m(svuint8_t inactive, svbool_t pg, svint8_t op)
84+
{
85+
// CHECK-LABEL: test_svclz_s8_m
86+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.clz.nxv16i8(<vscale x 16 x i8> %inactive, <vscale x 16 x i1> %pg, <vscale x 16 x i8> %op)
87+
// CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
88+
return SVE_ACLE_FUNC(svclz,_s8,_m,)(inactive, pg, op);
89+
}
90+
91+
svuint16_t test_svclz_s16_m(svuint16_t inactive, svbool_t pg, svint16_t op)
92+
{
93+
// CHECK-LABEL: test_svclz_s16_m
94+
// CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
95+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.clz.nxv8i16(<vscale x 8 x i16> %inactive, <vscale x 8 x i1> %[[PG]], <vscale x 8 x i16> %op)
96+
// CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
97+
return SVE_ACLE_FUNC(svclz,_s16,_m,)(inactive, pg, op);
98+
}
99+
100+
svuint32_t test_svclz_s32_m(svuint32_t inactive, svbool_t pg, svint32_t op)
101+
{
102+
// CHECK-LABEL: test_svclz_s32_m
103+
// CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
104+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.clz.nxv4i32(<vscale x 4 x i32> %inactive, <vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %op)
105+
// CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
106+
return SVE_ACLE_FUNC(svclz,_s32,_m,)(inactive, pg, op);
107+
}
108+
109+
svuint64_t test_svclz_s64_m(svuint64_t inactive, svbool_t pg, svint64_t op)
110+
{
111+
// CHECK-LABEL: test_svclz_s64_m
112+
// CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
113+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.clz.nxv2i64(<vscale x 2 x i64> %inactive, <vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %op)
114+
// CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
115+
return SVE_ACLE_FUNC(svclz,_s64,_m,)(inactive, pg, op);
116+
}
117+
118+
svuint8_t test_svclz_u8_m(svuint8_t inactive, svbool_t pg, svuint8_t op)
119+
{
120+
// CHECK-LABEL: test_svclz_u8_m
121+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.clz.nxv16i8(<vscale x 16 x i8> %inactive, <vscale x 16 x i1> %pg, <vscale x 16 x i8> %op)
122+
// CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
123+
return SVE_ACLE_FUNC(svclz,_u8,_m,)(inactive, pg, op);
124+
}
125+
126+
svuint16_t test_svclz_u16_m(svuint16_t inactive, svbool_t pg, svuint16_t op)
127+
{
128+
// CHECK-LABEL: test_svclz_u16_m
129+
// CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
130+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.clz.nxv8i16(<vscale x 8 x i16> %inactive, <vscale x 8 x i1> %[[PG]], <vscale x 8 x i16> %op)
131+
// CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
132+
return SVE_ACLE_FUNC(svclz,_u16,_m,)(inactive, pg, op);
133+
}
134+
135+
svuint32_t test_svclz_u32_m(svuint32_t inactive, svbool_t pg, svuint32_t op)
136+
{
137+
// CHECK-LABEL: test_svclz_u32_m
138+
// CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
139+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.clz.nxv4i32(<vscale x 4 x i32> %inactive, <vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %op)
140+
// CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
141+
return SVE_ACLE_FUNC(svclz,_u32,_m,)(inactive, pg, op);
142+
}
143+
144+
svuint64_t test_svclz_u64_m(svuint64_t inactive, svbool_t pg, svuint64_t op)
145+
{
146+
// CHECK-LABEL: test_svclz_u64_m
147+
// CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
148+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.clz.nxv2i64(<vscale x 2 x i64> %inactive, <vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %op)
149+
// CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
150+
return SVE_ACLE_FUNC(svclz,_u64,_m,)(inactive, pg, op);
151+
}
152+
153+
svuint8_t test_svclz_s8_x(svbool_t pg, svint8_t op)
154+
{
155+
// CHECK-LABEL: test_svclz_s8_x
156+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.clz.nxv16i8(<vscale x 16 x i8> undef, <vscale x 16 x i1> %pg, <vscale x 16 x i8> %op)
157+
// CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
158+
return SVE_ACLE_FUNC(svclz,_s8,_x,)(pg, op);
159+
}
160+
161+
svuint16_t test_svclz_s16_x(svbool_t pg, svint16_t op)
162+
{
163+
// CHECK-LABEL: test_svclz_s16_x
164+
// CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
165+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.clz.nxv8i16(<vscale x 8 x i16> undef, <vscale x 8 x i1> %[[PG]], <vscale x 8 x i16> %op)
166+
// CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
167+
return SVE_ACLE_FUNC(svclz,_s16,_x,)(pg, op);
168+
}
169+
170+
svuint32_t test_svclz_s32_x(svbool_t pg, svint32_t op)
171+
{
172+
// CHECK-LABEL: test_svclz_s32_x
173+
// CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
174+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.clz.nxv4i32(<vscale x 4 x i32> undef, <vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %op)
175+
// CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
176+
return SVE_ACLE_FUNC(svclz,_s32,_x,)(pg, op);
177+
}
178+
179+
svuint64_t test_svclz_s64_x(svbool_t pg, svint64_t op)
180+
{
181+
// CHECK-LABEL: test_svclz_s64_x
182+
// CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
183+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.clz.nxv2i64(<vscale x 2 x i64> undef, <vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %op)
184+
// CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
185+
return SVE_ACLE_FUNC(svclz,_s64,_x,)(pg, op);
186+
}
187+
188+
svuint8_t test_svclz_u8_x(svbool_t pg, svuint8_t op)
189+
{
190+
// CHECK-LABEL: test_svclz_u8_x
191+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.clz.nxv16i8(<vscale x 16 x i8> undef, <vscale x 16 x i1> %pg, <vscale x 16 x i8> %op)
192+
// CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
193+
return SVE_ACLE_FUNC(svclz,_u8,_x,)(pg, op);
194+
}
195+
196+
svuint16_t test_svclz_u16_x(svbool_t pg, svuint16_t op)
197+
{
198+
// CHECK-LABEL: test_svclz_u16_x
199+
// CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
200+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.clz.nxv8i16(<vscale x 8 x i16> undef, <vscale x 8 x i1> %[[PG]], <vscale x 8 x i16> %op)
201+
// CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
202+
return SVE_ACLE_FUNC(svclz,_u16,_x,)(pg, op);
203+
}
204+
205+
svuint32_t test_svclz_u32_x(svbool_t pg, svuint32_t op)
206+
{
207+
// CHECK-LABEL: test_svclz_u32_x
208+
// CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
209+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.clz.nxv4i32(<vscale x 4 x i32> undef, <vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %op)
210+
// CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
211+
return SVE_ACLE_FUNC(svclz,_u32,_x,)(pg, op);
212+
}
213+
214+
svuint64_t test_svclz_u64_x(svbool_t pg, svuint64_t op)
215+
{
216+
// CHECK-LABEL: test_svclz_u64_x
217+
// CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
218+
// CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.clz.nxv2i64(<vscale x 2 x i64> undef, <vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %op)
219+
// CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
220+
return SVE_ACLE_FUNC(svclz,_u64,_x,)(pg, op);
221+
}

0 commit comments

Comments
 (0)