[clang] 1d7b4a7 - [SveEmitter] Add builtins for tuple creation (svcreate2/svcreate3/etc)

Sander de Smalen via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 18 02:07:56 PDT 2020


Author: Sander de Smalen
Date: 2020-06-18T10:07:09+01:00
New Revision: 1d7b4a7e5e4a25605ec9926da1fb461840a1f216

URL: https://github.com/llvm/llvm-project/commit/1d7b4a7e5e4a25605ec9926da1fb461840a1f216
DIFF: https://github.com/llvm/llvm-project/commit/1d7b4a7e5e4a25605ec9926da1fb461840a1f216.diff

LOG: [SveEmitter] Add builtins for tuple creation (svcreate2/svcreate3/etc)

The svcreate builtins allow constructing a tuple from individual vectors, e.g.

  svint32x2_t svcreate2(svint32_t v2, svint32_t v2)`

Reviewers: c-rhodes, david-arm, efriedma

Reviewed By: c-rhodes, efriedma

Tags: #clang

Differential Revision: https://reviews.llvm.org/D81463

Added: 
    clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create2.c
    clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create3.c
    clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create4.c

Modified: 
    clang/include/clang/Basic/TargetBuiltins.h
    clang/include/clang/Basic/arm_sve.td
    clang/lib/CodeGen/CGBuiltin.cpp
    clang/lib/CodeGen/CodeGenFunction.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/TargetBuiltins.h b/clang/include/clang/Basic/TargetBuiltins.h
index 899f6b5b6f3c..38d82d1d869f 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -247,6 +247,7 @@ namespace clang {
     bool isGatherPrefetch() const { return Flags & IsGatherPrefetch; }
     bool isReverseUSDOT() const { return Flags & ReverseUSDOT; }
     bool isUndef() const { return Flags & IsUndef; }
+    bool isTupleCreate() const { return Flags & IsTupleCreate; }
 
     uint64_t getBits() const { return Flags; }
     bool isFlagSet(uint64_t Flag) const { return Flags & Flag; }

diff  --git a/clang/include/clang/Basic/arm_sve.td b/clang/include/clang/Basic/arm_sve.td
index a7223f770455..0348a3754e22 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -200,6 +200,7 @@ def IsGatherPrefetch          : FlagType<0x10000000>;
 def ReverseCompare            : FlagType<0x20000000>; // Compare operands must be swapped.
 def ReverseUSDOT              : FlagType<0x40000000>; // Unsigned/signed operands must be swapped.
 def IsUndef                   : FlagType<0x80000000>; // Codegen `undef` of given type.
+def IsTupleCreate             : FlagType<0x100000000>;
 
 // These must be kept in sync with the flags in include/clang/Basic/TargetBuiltins.h
 class ImmCheckType<int val> {
@@ -1279,6 +1280,10 @@ def SVUNDEF_2 : SInst<"svundef2_{d}", "2", "csilUcUsUiUlhfd", MergeNone, "", [Is
 def SVUNDEF_3 : SInst<"svundef3_{d}", "3", "csilUcUsUiUlhfd", MergeNone, "", [IsUndef]>;
 def SVUNDEF_4 : SInst<"svundef4_{d}", "4", "csilUcUsUiUlhfd", MergeNone, "", [IsUndef]>;
 
+def SVCREATE_2 : SInst<"svcreate2[_{d}]", "2dd",   "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_tuple_create2", [IsTupleCreate]>;
+def SVCREATE_3 : SInst<"svcreate3[_{d}]", "3ddd",  "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_tuple_create3", [IsTupleCreate]>;
+def SVCREATE_4 : SInst<"svcreate4[_{d}]", "4dddd", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_tuple_create4", [IsTupleCreate]>;
+
 ////////////////////////////////////////////////////////////////////////////////
 // SVE2 WhileGE/GT
 let ArchGuard = "defined(__ARM_FEATURE_SVE2)" in {

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index b81b2a449425..05de88c392aa 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -4646,7 +4646,7 @@ struct ARMVectorIntrinsicInfo {
   unsigned BuiltinID;
   unsigned LLVMIntrinsic;
   unsigned AltLLVMIntrinsic;
-  unsigned TypeModifier;
+  uint64_t TypeModifier;
 
   bool operator<(unsigned RHSBuiltinID) const {
     return BuiltinID < RHSBuiltinID;
@@ -7998,9 +7998,8 @@ static void InsertExplicitUndefOperand(CGBuilderTy &Builder, llvm::Type *Ty,
   Ops.insert(Ops.begin(), SplatUndef);
 }
 
-SmallVector<llvm::Type *, 2>
-CodeGenFunction::getSVEOverloadTypes(SVETypeFlags TypeFlags,
-                                     ArrayRef<Value *> Ops) {
+SmallVector<llvm::Type *, 2> CodeGenFunction::getSVEOverloadTypes(
+    SVETypeFlags TypeFlags, llvm::Type *ResultType, ArrayRef<Value *> Ops) {
   if (TypeFlags.isOverloadNone())
     return {};
 
@@ -8015,6 +8014,9 @@ CodeGenFunction::getSVEOverloadTypes(SVETypeFlags TypeFlags,
   if (TypeFlags.isOverloadCvt())
     return {Ops[0]->getType(), Ops.back()->getType()};
 
+  if (TypeFlags.isTupleCreate())
+    return {ResultType, Ops[0]->getType()};
+
   assert(TypeFlags.isOverloadDefault() && "Unexpected value for overloads");
   return {DefaultType};
 }
@@ -8112,7 +8114,7 @@ Value *CodeGenFunction::EmitAArch64SVEBuiltinExpr(unsigned BuiltinID,
     }
 
     Function *F = CGM.getIntrinsic(Builtin->LLVMIntrinsic,
-                                   getSVEOverloadTypes(TypeFlags, Ops));
+                                   getSVEOverloadTypes(TypeFlags, Ty, Ops));
     Value *Call = Builder.CreateCall(F, Ops);
 
     // Predicate results must be converted to svbool_t.

diff  --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 273aa1c962c3..935e8551d414 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -3956,6 +3956,7 @@ class CodeGenFunction : public CodeGenTypeCache {
   llvm::Type *SVEBuiltinMemEltTy(SVETypeFlags TypeFlags);
 
   SmallVector<llvm::Type *, 2> getSVEOverloadTypes(SVETypeFlags TypeFlags,
+                                                   llvm::Type *ReturnType,
                                                    ArrayRef<llvm::Value *> Ops);
   llvm::Type *getEltType(SVETypeFlags TypeFlags);
   llvm::ScalableVectorType *getSVEType(const SVETypeFlags &TypeFlags);

diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create2.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create2.c
new file mode 100644
index 000000000000..5f5de0a473e7
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create2.c
@@ -0,0 +1,99 @@
+// 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
+// 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
+
+#include <arm_sve.h>
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svint8x2_t test_svcreate2_s8(svint8_t x0, svint8_t x1)
+{
+  // CHECK-LABEL: test_svcreate2_s8
+  // CHECK: %[[CREATE:.*]] = call <vscale x 32 x i8> @llvm.aarch64.sve.tuple.create2.nxv32i8.nxv16i8(<vscale x 16 x i8> %x0, <vscale x 16 x i8> %x1)
+  // CHECK-NEXT: ret <vscale x 32 x i8> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate2,_s8,,)(x0, x1);
+}
+
+svint16x2_t test_svcreate2_s16(svint16_t x0, svint16_t x1)
+{
+  // CHECK-LABEL: test_svcreate2_s16
+  // CHECK: %[[CREATE:.*]] = call <vscale x 16 x i16> @llvm.aarch64.sve.tuple.create2.nxv16i16.nxv8i16(<vscale x 8 x i16> %x0, <vscale x 8 x i16> %x1)
+  // CHECK-NEXT: ret <vscale x 16 x i16> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate2,_s16,,)(x0, x1);
+}
+
+svint32x2_t test_svcreate2_s32(svint32_t x0, svint32_t x1)
+{
+  // CHECK-LABEL: test_svcreate2_s32
+  // CHECK: %[[CREATE:.*]] = call <vscale x 8 x i32> @llvm.aarch64.sve.tuple.create2.nxv8i32.nxv4i32(<vscale x 4 x i32> %x0, <vscale x 4 x i32> %x1)
+  // CHECK-NEXT: ret <vscale x 8 x i32> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate2,_s32,,)(x0, x1);
+}
+
+svint64x2_t test_svcreate2_s64(svint64_t x0, svint64_t x1)
+{
+  // CHECK-LABEL: test_svcreate2_s64
+  // CHECK: %[[CREATE:.*]] = call <vscale x 4 x i64> @llvm.aarch64.sve.tuple.create2.nxv4i64.nxv2i64(<vscale x 2 x i64> %x0, <vscale x 2 x i64> %x1)
+  // CHECK-NEXT: ret <vscale x 4 x i64> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate2,_s64,,)(x0, x1);
+}
+
+svuint8x2_t test_svcreate2_u8(svuint8_t x0, svuint8_t x1)
+{
+  // CHECK-LABEL: test_svcreate2_u8
+  // CHECK: %[[CREATE:.*]] = call <vscale x 32 x i8> @llvm.aarch64.sve.tuple.create2.nxv32i8.nxv16i8(<vscale x 16 x i8> %x0, <vscale x 16 x i8> %x1)
+  // CHECK-NEXT: ret <vscale x 32 x i8> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate2,_u8,,)(x0, x1);
+}
+
+svuint16x2_t test_svcreate2_u16(svuint16_t x0, svuint16_t x1)
+{
+  // CHECK-LABEL: test_svcreate2_u16
+  // CHECK: %[[CREATE:.*]] = call <vscale x 16 x i16> @llvm.aarch64.sve.tuple.create2.nxv16i16.nxv8i16(<vscale x 8 x i16> %x0, <vscale x 8 x i16> %x1)
+  // CHECK-NEXT: ret <vscale x 16 x i16> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate2,_u16,,)(x0, x1);
+}
+
+svuint32x2_t test_svcreate2_u32(svuint32_t x0, svuint32_t x1)
+{
+  // CHECK-LABEL: test_svcreate2_u32
+  // CHECK: %[[CREATE:.*]] = call <vscale x 8 x i32> @llvm.aarch64.sve.tuple.create2.nxv8i32.nxv4i32(<vscale x 4 x i32> %x0, <vscale x 4 x i32> %x1)
+  // CHECK-NEXT: ret <vscale x 8 x i32> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate2,_u32,,)(x0, x1);
+}
+
+svuint64x2_t test_svcreate2_u64(svuint64_t x0, svuint64_t x1)
+{
+  // CHECK-LABEL: test_svcreate2_u64
+  // CHECK: %[[CREATE:.*]] = call <vscale x 4 x i64> @llvm.aarch64.sve.tuple.create2.nxv4i64.nxv2i64(<vscale x 2 x i64> %x0, <vscale x 2 x i64> %x1)
+  // CHECK-NEXT: ret <vscale x 4 x i64> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate2,_u64,,)(x0, x1);
+}
+
+svfloat16x2_t test_svcreate2_f16(svfloat16_t x0, svfloat16_t x1)
+{
+  // CHECK-LABEL: test_svcreate2_f16
+  // CHECK: %[[CREATE:.*]] = call <vscale x 16 x half> @llvm.aarch64.sve.tuple.create2.nxv16f16.nxv8f16(<vscale x 8 x half> %x0, <vscale x 8 x half> %x1)
+  // CHECK-NEXT: ret <vscale x 16 x half> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate2,_f16,,)(x0, x1);
+}
+
+svfloat32x2_t test_svcreate2_f32(svfloat32_t x0, svfloat32_t x1)
+{
+  // CHECK-LABEL: test_svcreate2_f32
+  // CHECK: %[[CREATE:.*]] = call <vscale x 8 x float> @llvm.aarch64.sve.tuple.create2.nxv8f32.nxv4f32(<vscale x 4 x float> %x0, <vscale x 4 x float> %x1)
+  // CHECK-NEXT: ret <vscale x 8 x float> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate2,_f32,,)(x0, x1);
+}
+
+svfloat64x2_t test_svcreate2_f64(svfloat64_t x0, svfloat64_t x1)
+{
+  // CHECK-LABEL: test_svcreate2_f64
+  // CHECK: %[[CREATE:.*]] = call <vscale x 4 x double> @llvm.aarch64.sve.tuple.create2.nxv4f64.nxv2f64(<vscale x 2 x double> %x0, <vscale x 2 x double> %x1)
+  // CHECK-NEXT: ret <vscale x 4 x double> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate2,_f64,,)(x0, x1);
+}

diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create3.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create3.c
new file mode 100644
index 000000000000..b08ce21f199c
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create3.c
@@ -0,0 +1,99 @@
+// 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
+// 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
+
+#include <arm_sve.h>
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svint8x3_t test_svcreate3_s8(svint8_t x0, svint8_t x1, svint8_t x2)
+{
+  // CHECK-LABEL: test_svcreate3_s8
+  // CHECK: %[[CREATE:.*]] = call <vscale x 48 x i8> @llvm.aarch64.sve.tuple.create3.nxv48i8.nxv16i8(<vscale x 16 x i8> %x0, <vscale x 16 x i8> %x1, <vscale x 16 x i8> %x2)
+  // CHECK-NEXT: ret <vscale x 48 x i8> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate3,_s8,,)(x0, x1, x2);
+}
+
+svint16x3_t test_svcreate3_s16(svint16_t x0, svint16_t x1, svint16_t x2)
+{
+  // CHECK-LABEL: test_svcreate3_s16
+  // CHECK: %[[CREATE:.*]] = call <vscale x 24 x i16> @llvm.aarch64.sve.tuple.create3.nxv24i16.nxv8i16(<vscale x 8 x i16> %x0, <vscale x 8 x i16> %x1, <vscale x 8 x i16> %x2)
+  // CHECK-NEXT: ret <vscale x 24 x i16> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate3,_s16,,)(x0, x1, x2);
+}
+
+svint32x3_t test_svcreate3_s32(svint32_t x0, svint32_t x1, svint32_t x2)
+{
+  // CHECK-LABEL: test_svcreate3_s32
+  // CHECK: %[[CREATE:.*]] = call <vscale x 12 x i32> @llvm.aarch64.sve.tuple.create3.nxv12i32.nxv4i32(<vscale x 4 x i32> %x0, <vscale x 4 x i32> %x1, <vscale x 4 x i32> %x2)
+  // CHECK-NEXT: ret <vscale x 12 x i32> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate3,_s32,,)(x0, x1, x2);
+}
+
+svint64x3_t test_svcreate3_s64(svint64_t x0, svint64_t x1, svint64_t x2)
+{
+  // CHECK-LABEL: test_svcreate3_s64
+  // CHECK: %[[CREATE:.*]] = call <vscale x 6 x i64> @llvm.aarch64.sve.tuple.create3.nxv6i64.nxv2i64(<vscale x 2 x i64> %x0, <vscale x 2 x i64> %x1, <vscale x 2 x i64> %x2)
+  // CHECK-NEXT: ret <vscale x 6 x i64> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate3,_s64,,)(x0, x1, x2);
+}
+
+svuint8x3_t test_svcreate3_u8(svuint8_t x0, svuint8_t x1, svuint8_t x2)
+{
+  // CHECK-LABEL: test_svcreate3_u8
+  // CHECK: %[[CREATE:.*]] = call <vscale x 48 x i8> @llvm.aarch64.sve.tuple.create3.nxv48i8.nxv16i8(<vscale x 16 x i8> %x0, <vscale x 16 x i8> %x1, <vscale x 16 x i8> %x2)
+  // CHECK-NEXT: ret <vscale x 48 x i8> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate3,_u8,,)(x0, x1, x2);
+}
+
+svuint16x3_t test_svcreate3_u16(svuint16_t x0, svuint16_t x1, svuint16_t x2)
+{
+  // CHECK-LABEL: test_svcreate3_u16
+  // CHECK: %[[CREATE:.*]] = call <vscale x 24 x i16> @llvm.aarch64.sve.tuple.create3.nxv24i16.nxv8i16(<vscale x 8 x i16> %x0, <vscale x 8 x i16> %x1, <vscale x 8 x i16> %x2)
+  // CHECK-NEXT: ret <vscale x 24 x i16> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate3,_u16,,)(x0, x1, x2);
+}
+
+svuint32x3_t test_svcreate3_u32(svuint32_t x0, svuint32_t x1, svuint32_t x2)
+{
+  // CHECK-LABEL: test_svcreate3_u32
+  // CHECK: %[[CREATE:.*]] = call <vscale x 12 x i32> @llvm.aarch64.sve.tuple.create3.nxv12i32.nxv4i32(<vscale x 4 x i32> %x0, <vscale x 4 x i32> %x1, <vscale x 4 x i32> %x2)
+  // CHECK-NEXT: ret <vscale x 12 x i32> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate3,_u32,,)(x0, x1, x2);
+}
+
+svuint64x3_t test_svcreate3_u64(svuint64_t x0, svuint64_t x1, svuint64_t x2)
+{
+  // CHECK-LABEL: test_svcreate3_u64
+  // CHECK: %[[CREATE:.*]] = call <vscale x 6 x i64> @llvm.aarch64.sve.tuple.create3.nxv6i64.nxv2i64(<vscale x 2 x i64> %x0, <vscale x 2 x i64> %x1, <vscale x 2 x i64> %x2)
+  // CHECK-NEXT: ret <vscale x 6 x i64> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate3,_u64,,)(x0, x1, x2);
+}
+
+svfloat16x3_t test_svcreate3_f16(svfloat16_t x0, svfloat16_t x1, svfloat16_t x2)
+{
+  // CHECK-LABEL: test_svcreate3_f16
+  // CHECK: %[[CREATE:.*]] = call <vscale x 24 x half> @llvm.aarch64.sve.tuple.create3.nxv24f16.nxv8f16(<vscale x 8 x half> %x0, <vscale x 8 x half> %x1, <vscale x 8 x half> %x2)
+  // CHECK-NEXT: ret <vscale x 24 x half> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate3,_f16,,)(x0, x1, x2);
+}
+
+svfloat32x3_t test_svcreate3_f32(svfloat32_t x0, svfloat32_t x1, svfloat32_t x2)
+{
+  // CHECK-LABEL: test_svcreate3_f32
+  // CHECK: %[[CREATE:.*]] = call <vscale x 12 x float> @llvm.aarch64.sve.tuple.create3.nxv12f32.nxv4f32(<vscale x 4 x float> %x0, <vscale x 4 x float> %x1, <vscale x 4 x float> %x2)
+  // CHECK-NEXT: ret <vscale x 12 x float> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate3,_f32,,)(x0, x1, x2);
+}
+
+svfloat64x3_t test_svcreate3_f64(svfloat64_t x0, svfloat64_t x1, svfloat64_t x2)
+{
+  // CHECK-LABEL: test_svcreate3_f64
+  // CHECK: %[[CREATE:.*]] = call <vscale x 6 x double> @llvm.aarch64.sve.tuple.create3.nxv6f64.nxv2f64(<vscale x 2 x double> %x0, <vscale x 2 x double> %x1, <vscale x 2 x double> %x2)
+  // CHECK-NEXT: ret <vscale x 6 x double> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate3,_f64,,)(x0, x1, x2);
+}

diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create4.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create4.c
new file mode 100644
index 000000000000..ff05e4ac9946
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create4.c
@@ -0,0 +1,99 @@
+// 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
+// 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
+
+#include <arm_sve.h>
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svint8x4_t test_svcreate4_s8(svint8_t x0, svint8_t x1, svint8_t x2, svint8_t x4)
+{
+  // CHECK-LABEL: test_svcreate4_s8
+  // CHECK: %[[CREATE:.*]] = call <vscale x 64 x i8> @llvm.aarch64.sve.tuple.create4.nxv64i8.nxv16i8(<vscale x 16 x i8> %x0, <vscale x 16 x i8> %x1, <vscale x 16 x i8> %x2, <vscale x 16 x i8> %x4)
+  // CHECK-NEXT: ret <vscale x 64 x i8> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate4,_s8,,)(x0, x1, x2, x4);
+}
+
+svint16x4_t test_svcreate4_s16(svint16_t x0, svint16_t x1, svint16_t x2, svint16_t x4)
+{
+  // CHECK-LABEL: test_svcreate4_s16
+  // CHECK: %[[CREATE:.*]] = call <vscale x 32 x i16> @llvm.aarch64.sve.tuple.create4.nxv32i16.nxv8i16(<vscale x 8 x i16> %x0, <vscale x 8 x i16> %x1, <vscale x 8 x i16> %x2, <vscale x 8 x i16> %x4)
+  // CHECK-NEXT: ret <vscale x 32 x i16> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate4,_s16,,)(x0, x1, x2, x4);
+}
+
+svint32x4_t test_svcreate4_s32(svint32_t x0, svint32_t x1, svint32_t x2, svint32_t x4)
+{
+  // CHECK-LABEL: test_svcreate4_s32
+  // CHECK: %[[CREATE:.*]] = call <vscale x 16 x i32> @llvm.aarch64.sve.tuple.create4.nxv16i32.nxv4i32(<vscale x 4 x i32> %x0, <vscale x 4 x i32> %x1, <vscale x 4 x i32> %x2, <vscale x 4 x i32> %x4)
+  // CHECK-NEXT: ret <vscale x 16 x i32> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate4,_s32,,)(x0, x1, x2, x4);
+}
+
+svint64x4_t test_svcreate4_s64(svint64_t x0, svint64_t x1, svint64_t x2, svint64_t x4)
+{
+  // CHECK-LABEL: test_svcreate4_s64
+  // CHECK: %[[CREATE:.*]] = call <vscale x 8 x i64> @llvm.aarch64.sve.tuple.create4.nxv8i64.nxv2i64(<vscale x 2 x i64> %x0, <vscale x 2 x i64> %x1, <vscale x 2 x i64> %x2, <vscale x 2 x i64> %x4)
+  // CHECK-NEXT: ret <vscale x 8 x i64> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate4,_s64,,)(x0, x1, x2, x4);
+}
+
+svuint8x4_t test_svcreate4_u8(svuint8_t x0, svuint8_t x1, svuint8_t x2, svuint8_t x4)
+{
+  // CHECK-LABEL: test_svcreate4_u8
+  // CHECK: %[[CREATE:.*]] = call <vscale x 64 x i8> @llvm.aarch64.sve.tuple.create4.nxv64i8.nxv16i8(<vscale x 16 x i8> %x0, <vscale x 16 x i8> %x1, <vscale x 16 x i8> %x2, <vscale x 16 x i8> %x4)
+  // CHECK-NEXT: ret <vscale x 64 x i8> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate4,_u8,,)(x0, x1, x2, x4);
+}
+
+svuint16x4_t test_svcreate4_u16(svuint16_t x0, svuint16_t x1, svuint16_t x2, svuint16_t x4)
+{
+  // CHECK-LABEL: test_svcreate4_u16
+  // CHECK: %[[CREATE:.*]] = call <vscale x 32 x i16> @llvm.aarch64.sve.tuple.create4.nxv32i16.nxv8i16(<vscale x 8 x i16> %x0, <vscale x 8 x i16> %x1, <vscale x 8 x i16> %x2, <vscale x 8 x i16> %x4)
+  // CHECK-NEXT: ret <vscale x 32 x i16> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate4,_u16,,)(x0, x1, x2, x4);
+}
+
+svuint32x4_t test_svcreate4_u32(svuint32_t x0, svuint32_t x1, svuint32_t x2, svuint32_t x4)
+{
+  // CHECK-LABEL: test_svcreate4_u32
+  // CHECK: %[[CREATE:.*]] = call <vscale x 16 x i32> @llvm.aarch64.sve.tuple.create4.nxv16i32.nxv4i32(<vscale x 4 x i32> %x0, <vscale x 4 x i32> %x1, <vscale x 4 x i32> %x2, <vscale x 4 x i32> %x4)
+  // CHECK-NEXT: ret <vscale x 16 x i32> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate4,_u32,,)(x0, x1, x2, x4);
+}
+
+svuint64x4_t test_svcreate4_u64(svuint64_t x0, svuint64_t x1, svuint64_t x2, svuint64_t x4)
+{
+  // CHECK-LABEL: test_svcreate4_u64
+  // CHECK: %[[CREATE:.*]] = call <vscale x 8 x i64> @llvm.aarch64.sve.tuple.create4.nxv8i64.nxv2i64(<vscale x 2 x i64> %x0, <vscale x 2 x i64> %x1, <vscale x 2 x i64> %x2, <vscale x 2 x i64> %x4)
+  // CHECK-NEXT: ret <vscale x 8 x i64> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate4,_u64,,)(x0, x1, x2, x4);
+}
+
+svfloat16x4_t test_svcreate4_f16(svfloat16_t x0, svfloat16_t x1, svfloat16_t x2, svfloat16_t x4)
+{
+  // CHECK-LABEL: test_svcreate4_f16
+  // CHECK: %[[CREATE:.*]] = call <vscale x 32 x half> @llvm.aarch64.sve.tuple.create4.nxv32f16.nxv8f16(<vscale x 8 x half> %x0, <vscale x 8 x half> %x1, <vscale x 8 x half> %x2, <vscale x 8 x half> %x4)
+  // CHECK-NEXT: ret <vscale x 32 x half> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate4,_f16,,)(x0, x1, x2, x4);
+}
+
+svfloat32x4_t test_svcreate4_f32(svfloat32_t x0, svfloat32_t x1, svfloat32_t x2, svfloat32_t x4)
+{
+  // CHECK-LABEL: test_svcreate4_f32
+  // CHECK: %[[CREATE:.*]] = call <vscale x 16 x float> @llvm.aarch64.sve.tuple.create4.nxv16f32.nxv4f32(<vscale x 4 x float> %x0, <vscale x 4 x float> %x1, <vscale x 4 x float> %x2, <vscale x 4 x float> %x4)
+  // CHECK-NEXT: ret <vscale x 16 x float> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate4,_f32,,)(x0, x1, x2, x4);
+}
+
+svfloat64x4_t test_svcreate4_f64(svfloat64_t x0, svfloat64_t x1, svfloat64_t x2, svfloat64_t x4)
+{
+  // CHECK-LABEL: test_svcreate4_f64
+  // CHECK: %[[CREATE:.*]] = call <vscale x 8 x double> @llvm.aarch64.sve.tuple.create4.nxv8f64.nxv2f64(<vscale x 2 x double> %x0, <vscale x 2 x double> %x1, <vscale x 2 x double> %x2, <vscale x 2 x double> %x4)
+  // CHECK-NEXT: ret <vscale x 8 x double> %[[CREATE]]
+  return SVE_ACLE_FUNC(svcreate4,_f64,,)(x0, x1, x2, x4);
+}


        


More information about the cfe-commits mailing list