https://github.com/momchil-velikov updated https://github.com/llvm/llvm-project/pull/99041
>From 886c48dd7efa227f8605bfafef4204cefbb75d6e Mon Sep 17 00:00:00 2001 From: Momchil Velikov <momchil.veli...@arm.com> Date: Mon, 15 Jul 2024 17:50:43 +0100 Subject: [PATCH 1/4] [AArch64] Implement NEON vamin/vamax intrinsics This patch implements the intrinsics of the form floatNxM_t vamin[q]_fN(floatNxM_t vn, floatNxM_t vm); floatNxM_t vamax[q]_fN(floatNxM_t vn, floatNxM_t vm); as defined in https://github.com/ARM-software/acle/pull/324 Co-authored-by: Hassnaa Hamdi <hassnaa.ha...@arm.com> --- clang/include/clang/Basic/arm_neon.td | 5 + clang/lib/CodeGen/CGBuiltin.cpp | 17 +++ .../aarch64-neon-faminmax-intrinsics.c | 112 ++++++++++++++++++ llvm/include/llvm/IR/IntrinsicsAArch64.td | 3 + .../lib/Target/AArch64/AArch64InstrFormats.td | 20 ++++ llvm/lib/Target/AArch64/AArch64InstrInfo.td | 6 +- llvm/test/CodeGen/AArch64/neon-famin-famax.ll | 96 +++++++++++++++ 7 files changed, 257 insertions(+), 2 deletions(-) create mode 100644 clang/test/CodeGen/aarch64-neon-faminmax-intrinsics.c create mode 100644 llvm/test/CodeGen/AArch64/neon-famin-famax.ll diff --git a/clang/include/clang/Basic/arm_neon.td b/clang/include/clang/Basic/arm_neon.td index 536c0652280b9d..d35fc6c449de0a 100644 --- a/clang/include/clang/Basic/arm_neon.td +++ b/clang/include/clang/Basic/arm_neon.td @@ -2115,3 +2115,8 @@ let ArchGuard = "defined(__aarch64__)", TargetGuard = "lut" in { def VLUTI4_BF_X2_Q : SInst<"vluti4_laneq_x2", ".2(<U)I", "Qb">; } } + +let ArchGuard = "defined(__aarch64__)", TargetGuard = "faminmax" in { + def FAMIN : WInst<"vamin", "...", "fhQdQfQh">; + def FAMAX : WInst<"vamax", "...", "fhQdQfQh">; +} diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index e826c1c6fbbd23..3625d783acdaf1 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -13570,6 +13570,23 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID, Int = Intrinsic::aarch64_neon_vluti4q_laneq_x2; return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vluti4q_laneq_x2"); } + + case NEON::BI__builtin_neon_vamin_f16: + case NEON::BI__builtin_neon_vaminq_f16: + case NEON::BI__builtin_neon_vamin_f32: + case NEON::BI__builtin_neon_vaminq_f32: + case NEON::BI__builtin_neon_vaminq_f64: { + Int = Intrinsic::aarch64_neon_famin; + return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "famin"); + } + case NEON::BI__builtin_neon_vamax_f16: + case NEON::BI__builtin_neon_vamaxq_f16: + case NEON::BI__builtin_neon_vamax_f32: + case NEON::BI__builtin_neon_vamaxq_f32: + case NEON::BI__builtin_neon_vamaxq_f64: { + Int = Intrinsic::aarch64_neon_famax; + return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "famax"); + } } } diff --git a/clang/test/CodeGen/aarch64-neon-faminmax-intrinsics.c b/clang/test/CodeGen/aarch64-neon-faminmax-intrinsics.c new file mode 100644 index 00000000000000..631e9738b85c5f --- /dev/null +++ b/clang/test/CodeGen/aarch64-neon-faminmax-intrinsics.c @@ -0,0 +1,112 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +#include <arm_neon.h> + +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +faminmax -O3 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +faminmax -S -O3 -Werror -Wall -o /dev/null %s + +// CHECK-LABEL: define dso_local <4 x half> @test_vamin_f16( +// CHECK-SAME: <4 x half> noundef [[VN:%.*]], <4 x half> noundef [[VM:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[FAMIN2_I:%.*]] = tail call <4 x half> @llvm.aarch64.neon.famin.v4f16(<4 x half> [[VN]], <4 x half> [[VM]]) +// CHECK-NEXT: ret <4 x half> [[FAMIN2_I]] +// +float16x4_t test_vamin_f16(float16x4_t vn, float16x4_t vm) { + return vamin_f16(vn, vm); +} + +// CHECK-LABEL: define dso_local <8 x half> @test_vaminq_f16( +// CHECK-SAME: <8 x half> noundef [[VN:%.*]], <8 x half> noundef [[VM:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[FAMIN2_I:%.*]] = tail call <8 x half> @llvm.aarch64.neon.famin.v8f16(<8 x half> [[VN]], <8 x half> [[VM]]) +// CHECK-NEXT: ret <8 x half> [[FAMIN2_I]] +// +float16x8_t test_vaminq_f16(float16x8_t vn, float16x8_t vm) { + return vaminq_f16(vn, vm); + +} + +// CHECK-LABEL: define dso_local <2 x float> @test_vamin_f32( +// CHECK-SAME: <2 x float> noundef [[VN:%.*]], <2 x float> noundef [[VM:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[FAMIN2_I:%.*]] = tail call <2 x float> @llvm.aarch64.neon.famin.v2f32(<2 x float> [[VN]], <2 x float> [[VM]]) +// CHECK-NEXT: ret <2 x float> [[FAMIN2_I]] +// +float32x2_t test_vamin_f32(float32x2_t vn, float32x2_t vm) { + return vamin_f32(vn, vm); + +} + +// CHECK-LABEL: define dso_local <4 x float> @test_vaminq_f32( +// CHECK-SAME: <4 x float> noundef [[VN:%.*]], <4 x float> noundef [[VM:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[FAMIN2_I:%.*]] = tail call <4 x float> @llvm.aarch64.neon.famin.v4f32(<4 x float> [[VN]], <4 x float> [[VM]]) +// CHECK-NEXT: ret <4 x float> [[FAMIN2_I]] +// +float32x4_t test_vaminq_f32(float32x4_t vn, float32x4_t vm) { + return vaminq_f32(vn, vm); + +} + +// CHECK-LABEL: define dso_local <2 x double> @test_vaminq_f64( +// CHECK-SAME: <2 x double> noundef [[VN:%.*]], <2 x double> noundef [[VM:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[FAMIN2_I:%.*]] = tail call <2 x double> @llvm.aarch64.neon.famin.v2f64(<2 x double> [[VN]], <2 x double> [[VM]]) +// CHECK-NEXT: ret <2 x double> [[FAMIN2_I]] +// +float64x2_t test_vaminq_f64(float64x2_t vn, float64x2_t vm) { + return vaminq_f64(vn, vm); +} + + +// CHECK-LABEL: define dso_local <4 x half> @test_vamax_f16( +// CHECK-SAME: <4 x half> noundef [[VN:%.*]], <4 x half> noundef [[VM:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[FAMAX2_I:%.*]] = tail call <4 x half> @llvm.aarch64.neon.famax.v4f16(<4 x half> [[VN]], <4 x half> [[VM]]) +// CHECK-NEXT: ret <4 x half> [[FAMAX2_I]] +// +float16x4_t test_vamax_f16(float16x4_t vn, float16x4_t vm) { + return vamax_f16(vn, vm); +} + +// CHECK-LABEL: define dso_local <8 x half> @test_vamaxq_f16( +// CHECK-SAME: <8 x half> noundef [[VN:%.*]], <8 x half> noundef [[VM:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[FAMAX2_I:%.*]] = tail call <8 x half> @llvm.aarch64.neon.famax.v8f16(<8 x half> [[VN]], <8 x half> [[VM]]) +// CHECK-NEXT: ret <8 x half> [[FAMAX2_I]] +// +float16x8_t test_vamaxq_f16(float16x8_t vn, float16x8_t vm) { + return vamaxq_f16(vn, vm); + +} + +// CHECK-LABEL: define dso_local <2 x float> @test_vamax_f32( +// CHECK-SAME: <2 x float> noundef [[VN:%.*]], <2 x float> noundef [[VM:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[FAMAX2_I:%.*]] = tail call <2 x float> @llvm.aarch64.neon.famax.v2f32(<2 x float> [[VN]], <2 x float> [[VM]]) +// CHECK-NEXT: ret <2 x float> [[FAMAX2_I]] +// +float32x2_t test_vamax_f32(float32x2_t vn, float32x2_t vm) { + return vamax_f32(vn, vm); + +} + +// CHECK-LABEL: define dso_local <4 x float> @test_vamaxq_f32( +// CHECK-SAME: <4 x float> noundef [[VN:%.*]], <4 x float> noundef [[VM:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[FAMAX2_I:%.*]] = tail call <4 x float> @llvm.aarch64.neon.famax.v4f32(<4 x float> [[VN]], <4 x float> [[VM]]) +// CHECK-NEXT: ret <4 x float> [[FAMAX2_I]] +// +float32x4_t test_vamaxq_f32(float32x4_t vn, float32x4_t vm) { + return vamaxq_f32(vn, vm); + +} + +// CHECK-LABEL: define dso_local <2 x double> @test_vamaxq_f64( +// CHECK-SAME: <2 x double> noundef [[VN:%.*]], <2 x double> noundef [[VM:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[FAMAX2_I:%.*]] = tail call <2 x double> @llvm.aarch64.neon.famax.v2f64(<2 x double> [[VN]], <2 x double> [[VM]]) +// CHECK-NEXT: ret <2 x double> [[FAMAX2_I]] +// +float64x2_t test_vamaxq_f64(float64x2_t vn, float64x2_t vm) { + return vamaxq_f64(vn, vm); +} diff --git a/llvm/include/llvm/IR/IntrinsicsAArch64.td b/llvm/include/llvm/IR/IntrinsicsAArch64.td index 9bce850750f793..62a0e6984f86df 100644 --- a/llvm/include/llvm/IR/IntrinsicsAArch64.td +++ b/llvm/include/llvm/IR/IntrinsicsAArch64.td @@ -3792,3 +3792,6 @@ def int_aarch64_sve_famax_u : AdvSIMD_Pred2VectorArg_Intrinsic; def int_aarch64_sve_famin : AdvSIMD_Pred2VectorArg_Intrinsic; def int_aarch64_sve_famin_u : AdvSIMD_Pred2VectorArg_Intrinsic; +// Neon absolute maximum and minimum +def int_aarch64_neon_famax : AdvSIMD_2VectorArg_Intrinsic; +def int_aarch64_neon_famin : AdvSIMD_2VectorArg_Intrinsic; diff --git a/llvm/lib/Target/AArch64/AArch64InstrFormats.td b/llvm/lib/Target/AArch64/AArch64InstrFormats.td index 16002011aedfbe..1777f65e378603 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrFormats.td +++ b/llvm/lib/Target/AArch64/AArch64InstrFormats.td @@ -5992,6 +5992,26 @@ multiclass SIMDThreeSameVectorFP<bit U, bit S, bits<3> opc, [(set (v2f64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (v2f64 V128:$Rm)))]>; } +let mayRaiseFPException = 1, Uses = [FPCR] in +multiclass SIMDThreeVectorFP<bit U, bit S, bits<3> opc, + string asm, SDPatternOperator OpNode> { + def v4f16 : BaseSIMDThreeSameVector<0, U, {S,0b10}, {0b00,opc}, V64, + asm, ".4h", + [(set (v4f16 V64:$Rd), (OpNode (v4f16 V64:$Rn), (v4i16 V64:$Rm)))]>; + def v8f16 : BaseSIMDThreeSameVector<1, U, {S,0b10}, {0b00,opc}, V128, + asm, ".8h", + [(set (v8f16 V128:$Rd), (OpNode (v8f16 V128:$Rn), (v8i16 V128:$Rm)))]>; + def v2f32 : BaseSIMDThreeSameVector<0, U, {S,0b01}, {0b11,opc}, V64, + asm, ".2s", + [(set (v2f32 V64:$Rd), (OpNode (v2f32 V64:$Rn), (v2i32 V64:$Rm)))]>; + def v4f32 : BaseSIMDThreeSameVector<1, U, {S,0b01}, {0b11,opc}, V128, + asm, ".4s", + [(set (v4f32 V128:$Rd), (OpNode (v4f32 V128:$Rn), (v4i32 V128:$Rm)))]>; + def v2f64 : BaseSIMDThreeSameVector<1, U, {S,0b11}, {0b11,opc}, V128, + asm, ".2d", + [(set (v2f64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (v2i64 V128:$Rm)))]>; +} + let mayRaiseFPException = 1, Uses = [FPCR] in multiclass SIMDThreeSameVectorFPCmp<bit U, bit S, bits<3> opc, string asm, diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td index ccef85bfaa8afc..7790cabd6db138 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td @@ -10134,13 +10134,15 @@ let Uses = [FPMR, FPCR], Predicates = [HasFP8] in { // fminimum(abs(a), abs(b)) -> famin(a, b) // fminnum[nnan](abs(a), abs(b)) -> famin(a, b) def AArch64famin : PatFrags<(ops node:$Rn, node:$Rm), - [(fminimum (fabs node:$Rn), (fabs node:$Rm)), + [(int_aarch64_neon_famin node:$Rn, node:$Rm), + (fminimum (fabs node:$Rn), (fabs node:$Rm)), (fminnum_nnan (fabs node:$Rn), (fabs node:$Rm))]>; // fmaximum(abs(a), abs(b)) -> famax(a, b) // fmaxnum[nnan](abs(a), abs(b)) -> famax(a, b) def AArch64famax : PatFrags<(ops node:$Rn, node:$Rm), - [(fmaximum (fabs node:$Rn), (fabs node:$Rm)), + [(int_aarch64_neon_famax node:$Rn, node:$Rm), + (fmaximum (fabs node:$Rn), (fabs node:$Rm)), (fmaxnum_nnan (fabs node:$Rn), (fabs node:$Rm))]>; let Predicates = [HasNEON, HasFAMINMAX] in { diff --git a/llvm/test/CodeGen/AArch64/neon-famin-famax.ll b/llvm/test/CodeGen/AArch64/neon-famin-famax.ll new file mode 100644 index 00000000000000..97fb0a08914524 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/neon-famin-famax.ll @@ -0,0 +1,96 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 +; RUN: llc < %s | FileCheck %s + +target triple = "aarch64-linux" + +define <4 x half> @test_famin_f16(<4 x half> %vn, <4 x half> %vm) #0 { +; CHECK-LABEL: test_famin_f16: +; CHECK: // %bb.0: +; CHECK-NEXT: famin v0.4h, v0.4h, v1.4h +; CHECK-NEXT: ret + %res = call <4 x half> @llvm.aarch64.neon.famin.v4f16(<4 x half> %vn, <4 x half> %vm) + ret <4 x half> %res +} + +define <8 x half> @test_famin2_f16(<8 x half> %vn, <8 x half> %vm) #0 { +; CHECK-LABEL: test_famin2_f16: +; CHECK: // %bb.0: +; CHECK-NEXT: famin v0.8h, v0.8h, v1.8h +; CHECK-NEXT: ret + %res = call <8 x half> @llvm.aarch64.neon.famin.v8f16(<8 x half> %vn, <8 x half> %vm) + ret <8 x half> %res +} + +define <2 x float> @test_famin_f32(<2 x float> %vn, <2 x float> %vm) #0 { +; CHECK-LABEL: test_famin_f32: +; CHECK: // %bb.0: +; CHECK-NEXT: famin v0.2s, v0.2s, v1.2s +; CHECK-NEXT: ret + %res = call <2 x float> @llvm.aarch64.neon.famin.v2f32(<2 x float> %vn, <2 x float> %vm) + ret <2 x float> %res +} + +define <4 x float> @test_famin2_f32(<4 x float> %vn, <4 x float> %vm) #0 { +; CHECK-LABEL: test_famin2_f32: +; CHECK: // %bb.0: +; CHECK-NEXT: famin v0.4s, v0.4s, v1.4s +; CHECK-NEXT: ret + %res = call <4 x float> @llvm.aarch64.neon.famin.v4f32(<4 x float> %vn, <4 x float> %vm) + ret <4 x float> %res +} + +define <2 x double> @test_famin_f64(<2 x double> %vn, <2 x double> %vm) #0 { +; CHECK-LABEL: test_famin_f64: +; CHECK: // %bb.0: +; CHECK-NEXT: famin v0.2d, v0.2d, v1.2d +; CHECK-NEXT: ret + %res = call <2 x double> @llvm.aarch64.neon.famin.v2f64(<2 x double> %vn, <2 x double> %vm) + ret <2 x double> %res +} + +define <4 x half> @test_famax_f16(<4 x half> %vn, <4 x half> %vm) #0 { +; CHECK-LABEL: test_famax_f16: +; CHECK: // %bb.0: +; CHECK-NEXT: famax v0.4h, v0.4h, v1.4h +; CHECK-NEXT: ret + %res = call <4 x half> @llvm.aarch64.neon.famax.v4f16(<4 x half> %vn, <4 x half> %vm) + ret <4 x half> %res +} + +define <8 x half> @test_famax2_f16(<8 x half> %vn, <8 x half> %vm) #0 { +; CHECK-LABEL: test_famax2_f16: +; CHECK: // %bb.0: +; CHECK-NEXT: famax v0.8h, v0.8h, v1.8h +; CHECK-NEXT: ret + %res = call <8 x half> @llvm.aarch64.neon.famax.v8f16(<8 x half> %vn, <8 x half> %vm) + ret <8 x half> %res +} + +define <2 x float> @test_famax_f32(<2 x float> %vn, <2 x float> %vm) #0 { +; CHECK-LABEL: test_famax_f32: +; CHECK: // %bb.0: +; CHECK-NEXT: famax v0.2s, v0.2s, v1.2s +; CHECK-NEXT: ret + %res = call <2 x float> @llvm.aarch64.neon.famax.v2f32(<2 x float> %vn, <2 x float> %vm) + ret <2 x float> %res +} + +define <4 x float> @test_famax2_f32(<4 x float> %vn, <4 x float> %vm) #0 { +; CHECK-LABEL: test_famax2_f32: +; CHECK: // %bb.0: +; CHECK-NEXT: famax v0.4s, v0.4s, v1.4s +; CHECK-NEXT: ret + %res = call <4 x float> @llvm.aarch64.neon.famax.v4f32(<4 x float> %vn, <4 x float> %vm) + ret <4 x float> %res +} + +define <2 x double> @test_famax_f64(<2 x double> %vn, <2 x double> %vm) #0 { +; CHECK-LABEL: test_famax_f64: +; CHECK: // %bb.0: +; CHECK-NEXT: famax v0.2d, v0.2d, v1.2d +; CHECK-NEXT: ret + %res = call <2 x double> @llvm.aarch64.neon.famax.v2f64(<2 x double> %vn, <2 x double> %vm) + ret <2 x double> %res +} + +attributes #0 = { "target-features"="+neon,+faminmax" } >From 2432946948ddb307d26af2a152958699b3a18893 Mon Sep 17 00:00:00 2001 From: Momchil Velikov <momchil.veli...@arm.com> Date: Fri, 26 Jul 2024 16:03:14 +0100 Subject: [PATCH 2/4] [fixup] Remove unused tablegen class --- .../lib/Target/AArch64/AArch64InstrFormats.td | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/llvm/lib/Target/AArch64/AArch64InstrFormats.td b/llvm/lib/Target/AArch64/AArch64InstrFormats.td index 1777f65e378603..16002011aedfbe 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrFormats.td +++ b/llvm/lib/Target/AArch64/AArch64InstrFormats.td @@ -5992,26 +5992,6 @@ multiclass SIMDThreeSameVectorFP<bit U, bit S, bits<3> opc, [(set (v2f64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (v2f64 V128:$Rm)))]>; } -let mayRaiseFPException = 1, Uses = [FPCR] in -multiclass SIMDThreeVectorFP<bit U, bit S, bits<3> opc, - string asm, SDPatternOperator OpNode> { - def v4f16 : BaseSIMDThreeSameVector<0, U, {S,0b10}, {0b00,opc}, V64, - asm, ".4h", - [(set (v4f16 V64:$Rd), (OpNode (v4f16 V64:$Rn), (v4i16 V64:$Rm)))]>; - def v8f16 : BaseSIMDThreeSameVector<1, U, {S,0b10}, {0b00,opc}, V128, - asm, ".8h", - [(set (v8f16 V128:$Rd), (OpNode (v8f16 V128:$Rn), (v8i16 V128:$Rm)))]>; - def v2f32 : BaseSIMDThreeSameVector<0, U, {S,0b01}, {0b11,opc}, V64, - asm, ".2s", - [(set (v2f32 V64:$Rd), (OpNode (v2f32 V64:$Rn), (v2i32 V64:$Rm)))]>; - def v4f32 : BaseSIMDThreeSameVector<1, U, {S,0b01}, {0b11,opc}, V128, - asm, ".4s", - [(set (v4f32 V128:$Rd), (OpNode (v4f32 V128:$Rn), (v4i32 V128:$Rm)))]>; - def v2f64 : BaseSIMDThreeSameVector<1, U, {S,0b11}, {0b11,opc}, V128, - asm, ".2d", - [(set (v2f64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (v2i64 V128:$Rm)))]>; -} - let mayRaiseFPException = 1, Uses = [FPCR] in multiclass SIMDThreeSameVectorFPCmp<bit U, bit S, bits<3> opc, string asm, >From fcbbb80347725b41ff003a8288fccbf6bdfb465c Mon Sep 17 00:00:00 2001 From: Momchil Velikov <momchil.veli...@arm.com> Date: Wed, 4 Sep 2024 18:20:36 +0100 Subject: [PATCH 3/4] [fixup] Add a REQUIRES clause to a test and rebase --- clang/test/CodeGen/aarch64-neon-faminmax-intrinsics.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/test/CodeGen/aarch64-neon-faminmax-intrinsics.c b/clang/test/CodeGen/aarch64-neon-faminmax-intrinsics.c index 631e9738b85c5f..3dc5afe68e7f46 100644 --- a/clang/test/CodeGen/aarch64-neon-faminmax-intrinsics.c +++ b/clang/test/CodeGen/aarch64-neon-faminmax-intrinsics.c @@ -1,9 +1,11 @@ // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 -#include <arm_neon.h> - // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +faminmax -O3 -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +faminmax -S -O3 -Werror -Wall -o /dev/null %s +// REQUIRES: aarch64-registered-target + +#include <arm_neon.h> + // CHECK-LABEL: define dso_local <4 x half> @test_vamin_f16( // CHECK-SAME: <4 x half> noundef [[VN:%.*]], <4 x half> noundef [[VM:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { // CHECK-NEXT: [[ENTRY:.*:]] >From 986eed885f425f9f968e67a364d596c74e5fb2b5 Mon Sep 17 00:00:00 2001 From: Momchil Velikov <momchil.veli...@arm.com> Date: Thu, 5 Sep 2024 12:16:43 +0100 Subject: [PATCH 4/4] [fixup] Add neon feature requirement --- clang/include/clang/Basic/arm_neon.td | 2 +- .../aarch64-neon-faminmax-intrinsics.c | 7 ---- .../Sema/aarch64-neon-faminmax-no-faminmax.c | 35 +++++++++++++++++++ .../test/Sema/aarch64-neon-faminmax-no-neon.c | 34 ++++++++++++++++++ 4 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 clang/test/Sema/aarch64-neon-faminmax-no-faminmax.c create mode 100644 clang/test/Sema/aarch64-neon-faminmax-no-neon.c diff --git a/clang/include/clang/Basic/arm_neon.td b/clang/include/clang/Basic/arm_neon.td index d35fc6c449de0a..c9e81dc1ed246a 100644 --- a/clang/include/clang/Basic/arm_neon.td +++ b/clang/include/clang/Basic/arm_neon.td @@ -2116,7 +2116,7 @@ let ArchGuard = "defined(__aarch64__)", TargetGuard = "lut" in { } } -let ArchGuard = "defined(__aarch64__)", TargetGuard = "faminmax" in { +let ArchGuard = "defined(__aarch64__)", TargetGuard = "neon,faminmax" in { def FAMIN : WInst<"vamin", "...", "fhQdQfQh">; def FAMAX : WInst<"vamax", "...", "fhQdQfQh">; } diff --git a/clang/test/CodeGen/aarch64-neon-faminmax-intrinsics.c b/clang/test/CodeGen/aarch64-neon-faminmax-intrinsics.c index 3dc5afe68e7f46..3ae98b5723d7c8 100644 --- a/clang/test/CodeGen/aarch64-neon-faminmax-intrinsics.c +++ b/clang/test/CodeGen/aarch64-neon-faminmax-intrinsics.c @@ -24,7 +24,6 @@ float16x4_t test_vamin_f16(float16x4_t vn, float16x4_t vm) { // float16x8_t test_vaminq_f16(float16x8_t vn, float16x8_t vm) { return vaminq_f16(vn, vm); - } // CHECK-LABEL: define dso_local <2 x float> @test_vamin_f32( @@ -35,7 +34,6 @@ float16x8_t test_vaminq_f16(float16x8_t vn, float16x8_t vm) { // float32x2_t test_vamin_f32(float32x2_t vn, float32x2_t vm) { return vamin_f32(vn, vm); - } // CHECK-LABEL: define dso_local <4 x float> @test_vaminq_f32( @@ -46,7 +44,6 @@ float32x2_t test_vamin_f32(float32x2_t vn, float32x2_t vm) { // float32x4_t test_vaminq_f32(float32x4_t vn, float32x4_t vm) { return vaminq_f32(vn, vm); - } // CHECK-LABEL: define dso_local <2 x double> @test_vaminq_f64( @@ -59,7 +56,6 @@ float64x2_t test_vaminq_f64(float64x2_t vn, float64x2_t vm) { return vaminq_f64(vn, vm); } - // CHECK-LABEL: define dso_local <4 x half> @test_vamax_f16( // CHECK-SAME: <4 x half> noundef [[VN:%.*]], <4 x half> noundef [[VM:%.*]]) local_unnamed_addr #[[ATTR0]] { // CHECK-NEXT: [[ENTRY:.*:]] @@ -78,7 +74,6 @@ float16x4_t test_vamax_f16(float16x4_t vn, float16x4_t vm) { // float16x8_t test_vamaxq_f16(float16x8_t vn, float16x8_t vm) { return vamaxq_f16(vn, vm); - } // CHECK-LABEL: define dso_local <2 x float> @test_vamax_f32( @@ -89,7 +84,6 @@ float16x8_t test_vamaxq_f16(float16x8_t vn, float16x8_t vm) { // float32x2_t test_vamax_f32(float32x2_t vn, float32x2_t vm) { return vamax_f32(vn, vm); - } // CHECK-LABEL: define dso_local <4 x float> @test_vamaxq_f32( @@ -100,7 +94,6 @@ float32x2_t test_vamax_f32(float32x2_t vn, float32x2_t vm) { // float32x4_t test_vamaxq_f32(float32x4_t vn, float32x4_t vm) { return vamaxq_f32(vn, vm); - } // CHECK-LABEL: define dso_local <2 x double> @test_vamaxq_f64( diff --git a/clang/test/Sema/aarch64-neon-faminmax-no-faminmax.c b/clang/test/Sema/aarch64-neon-faminmax-no-faminmax.c new file mode 100644 index 00000000000000..588f69cc7750b3 --- /dev/null +++ b/clang/test/Sema/aarch64-neon-faminmax-no-faminmax.c @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon -emit-llvm -verify %s -o /dev/null + +// REQUIRES: aarch64-registered-target + +#include <arm_neon.h> + +float16x4_t a16x4, b16x4; +float16x8_t a16x8, b16x8; +float32x2_t a32x2, b32x2; +float32x4_t a32x4, b32x4; +float64x2_t a64x2, b64x2; + + +void test() { + (void) vamin_f16 (a16x4, b16x4); +// expected-error@-1 {{always_inline function 'vamin_f16' requires target feature 'faminmax'}} + (void) vaminq_f16(a16x8, b16x8); +// expected-error@-1 {{always_inline function 'vaminq_f16' requires target feature 'faminmax'}} + (void) vamin_f32 (a32x2, b32x2); +// expected-error@-1 {{always_inline function 'vamin_f32' requires target feature 'faminmax'}} + (void) vaminq_f32(a32x4, b32x4); +// expected-error@-1 {{always_inline function 'vaminq_f32' requires target feature 'faminmax'}} + (void) vaminq_f64(a64x2, b64x2); +// expected-error@-1 {{always_inline function 'vaminq_f64' requires target feature 'faminmax'}} + (void) vamax_f16 (a16x4, b16x4); +// expected-error@-1 {{always_inline function 'vamax_f16' requires target feature 'faminmax'}} + (void) vamaxq_f16(a16x8, b16x8); +// expected-error@-1 {{always_inline function 'vamaxq_f16' requires target feature 'faminmax'}} + (void) vamax_f32 (a32x2, b32x2); +// expected-error@-1 {{always_inline function 'vamax_f32' requires target feature 'faminmax'}} + (void) vamaxq_f32(a32x4, b32x4); +// expected-error@-1 {{always_inline function 'vamaxq_f32' requires target feature 'faminmax'}} + (void) vamaxq_f64(a64x2, b64x2); +// expected-error@-1 {{always_inline function 'vamaxq_f64' requires target feature 'faminmax'}} +} diff --git a/clang/test/Sema/aarch64-neon-faminmax-no-neon.c b/clang/test/Sema/aarch64-neon-faminmax-no-neon.c new file mode 100644 index 00000000000000..a210e8398d9b74 --- /dev/null +++ b/clang/test/Sema/aarch64-neon-faminmax-no-neon.c @@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +faminmax -emit-llvm -verify %s -o /dev/null + +// REQUIRES: aarch64-registered-target + +#include <arm_neon.h> + +float16x4_t a16x4, b16x4; +float16x8_t a16x8, b16x8; +float32x2_t a32x2, b32x2; +float32x4_t a32x4, b32x4; +float64x2_t a64x2, b64x2; + +void test () { + (void) vamin_f16 (a16x4, b16x4); +// expected-error@-1 {{always_inline function 'vamin_f16' requires target feature 'neon'}} + (void) vaminq_f16(a16x8, b16x8); +// expected-error@-1 {{always_inline function 'vaminq_f16' requires target feature 'neon'}} + (void) vamin_f32 (a32x2, b32x2); +// expected-error@-1 {{always_inline function 'vamin_f32' requires target feature 'neon'}} + (void) vaminq_f32(a32x4, b32x4); +// expected-error@-1 {{always_inline function 'vaminq_f32' requires target feature 'neon'}} + (void) vaminq_f64(a64x2, b64x2); +// expected-error@-1 {{always_inline function 'vaminq_f64' requires target feature 'neon'}} + (void) vamax_f16 (a16x4, b16x4); +// expected-error@-1 {{always_inline function 'vamax_f16' requires target feature 'neon'}} + (void) vamaxq_f16(a16x8, b16x8); +// expected-error@-1 {{always_inline function 'vamaxq_f16' requires target feature 'neon'}} + (void) vamax_f32 (a32x2, b32x2); +// expected-error@-1 {{always_inline function 'vamax_f32' requires target feature 'neon'}} + (void) vamaxq_f32(a32x4, b32x4); +// expected-error@-1 {{always_inline function 'vamaxq_f32' requires target feature 'neon'}} + (void) vamaxq_f64(a64x2, b64x2); +// expected-error@-1 {{always_inline function 'vamaxq_f64' requires target feature 'neon'}} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits