1 // REQUIRES: aarch64-registered-target
2 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
3 // RUN: %clang_cc1 -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
4 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t
5 // RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
6 
7 // If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it.
8 // ASM-NOT: warning
9 #include <arm_sve.h>
10 
11 #ifdef SVE_OVERLOADED_FORMS
12 // A simple used,unused... macro, long enough to represent any SVE builtin.
13 #define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
14 #else
15 #define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
16 #endif
17 
test_svacle_f16(svbool_t pg,svfloat16_t op1,svfloat16_t op2)18 svbool_t test_svacle_f16(svbool_t pg, svfloat16_t op1, svfloat16_t op2)
19 {
20   // CHECK-LABEL: test_svacle_f16
21   // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
22   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.facge.nxv8f16(<vscale x 8 x i1> %[[PG]], <vscale x 8 x half> %op2, <vscale x 8 x half> %op1)
23   // CHECK: %[[CAST:.*]] = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv8i1(<vscale x 8 x i1> %[[INTRINSIC]])
24   // CHECK: ret <vscale x 16 x i1> %[[CAST]]
25   return SVE_ACLE_FUNC(svacle,_f16,,)(pg, op1, op2);
26 }
27 
test_svacle_f32(svbool_t pg,svfloat32_t op1,svfloat32_t op2)28 svbool_t test_svacle_f32(svbool_t pg, svfloat32_t op1, svfloat32_t op2)
29 {
30   // CHECK-LABEL: test_svacle_f32
31   // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
32   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.facge.nxv4f32(<vscale x 4 x i1> %[[PG]], <vscale x 4 x float> %op2, <vscale x 4 x float> %op1)
33   // CHECK: %[[CAST:.*]] = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv4i1(<vscale x 4 x i1> %[[INTRINSIC]])
34   // CHECK: ret <vscale x 16 x i1> %[[CAST]]
35   return SVE_ACLE_FUNC(svacle,_f32,,)(pg, op1, op2);
36 }
37 
test_svacle_f64(svbool_t pg,svfloat64_t op1,svfloat64_t op2)38 svbool_t test_svacle_f64(svbool_t pg, svfloat64_t op1, svfloat64_t op2)
39 {
40   // CHECK-LABEL: test_svacle_f64
41   // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
42   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.facge.nxv2f64(<vscale x 2 x i1> %[[PG]], <vscale x 2 x double> %op2, <vscale x 2 x double> %op1)
43   // CHECK: %[[CAST:.*]] = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv2i1(<vscale x 2 x i1> %[[INTRINSIC]])
44   // CHECK: ret <vscale x 16 x i1> %[[CAST]]
45   return SVE_ACLE_FUNC(svacle,_f64,,)(pg, op1, op2);
46 }
47 
test_svacle_n_f32(svbool_t pg,svfloat32_t op1,float32_t op2)48 svbool_t test_svacle_n_f32(svbool_t pg, svfloat32_t op1, float32_t op2)
49 {
50   // CHECK-LABEL: test_svacle_n_f32
51   // CHECK-DAG: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
52   // CHECK-DAG: %[[DUP:.*]] = call <vscale x 4 x float> @llvm.aarch64.sve.dup.x.nxv4f32(float %op2)
53   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.facge.nxv4f32(<vscale x 4 x i1> %[[PG]], <vscale x 4 x float> %[[DUP]], <vscale x 4 x float> %op1)
54   // CHECK: %[[CAST:.*]] = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv4i1(<vscale x 4 x i1> %[[INTRINSIC]])
55   // CHECK: ret <vscale x 16 x i1> %[[CAST]]
56   return SVE_ACLE_FUNC(svacle,_n_f32,,)(pg, op1, op2);
57 }
58 
test_svacle_n_f64(svbool_t pg,svfloat64_t op1,float64_t op2)59 svbool_t test_svacle_n_f64(svbool_t pg, svfloat64_t op1, float64_t op2)
60 {
61   // CHECK-LABEL: test_svacle_n_f64
62   // CHECK-DAG: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
63   // CHECK-DAG: %[[DUP:.*]] = call <vscale x 2 x double> @llvm.aarch64.sve.dup.x.nxv2f64(double %op2)
64   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.facge.nxv2f64(<vscale x 2 x i1> %[[PG]], <vscale x 2 x double> %[[DUP]], <vscale x 2 x double> %op1)
65   // CHECK: %[[CAST:.*]] = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv2i1(<vscale x 2 x i1> %[[INTRINSIC]])
66   // CHECK: ret <vscale x 16 x i1> %[[CAST]]
67   return SVE_ACLE_FUNC(svacle,_n_f64,,)(pg, op1, op2);
68 }
69