Index: llvm/include/llvm/IR/IntrinsicsAArch64.td =================================================================== --- llvm/include/llvm/IR/IntrinsicsAArch64.td +++ llvm/include/llvm/IR/IntrinsicsAArch64.td @@ -2684,6 +2684,8 @@ def int_aarch64_sve_sclamp : AdvSIMD_3VectorArg_Intrinsic; def int_aarch64_sve_uclamp : AdvSIMD_3VectorArg_Intrinsic; + def int_aarch64_sve_fclamp : AdvSIMD_3VectorArg_Intrinsic; + // // Reversal Index: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td =================================================================== --- llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td +++ llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td @@ -3673,7 +3673,7 @@ //===----------------------------------------------------------------------===// let Predicates = [HasSVE2p1_or_HasSME2] in { -defm FCLAMP_ZZZ : sve2p1_fclamp<"fclamp">; +defm FCLAMP_ZZZ : sve2p1_fclamp<"fclamp", int_aarch64_sve_fclamp>; def FDOT_ZZZ_S : sve_float_dot<0b0, "fdot">; def FDOT_ZZZI_S : sve_float_dot_indexed<0b0, "fdot">; def BFMLSLB_ZZZ_S : sve2_fp_mla_long<0b110, "bfmlslb">; Index: llvm/lib/Target/AArch64/SVEInstrFormats.td =================================================================== --- llvm/lib/Target/AArch64/SVEInstrFormats.td +++ llvm/lib/Target/AArch64/SVEInstrFormats.td @@ -8725,10 +8725,14 @@ let ElementSize = zpr_ty.ElementSize; } -multiclass sve2p1_fclamp { +multiclass sve2p1_fclamp { def _H : sve2p1_fclamp; def _S : sve2p1_fclamp; def _D : sve2p1_fclamp; + + def : SVE_3_Op_Pat(NAME # _H)>; + def : SVE_3_Op_Pat(NAME # _S)>; + def : SVE_3_Op_Pat(NAME # _D)>; } // SVE two-way dot product Index: llvm/test/CodeGen/AArch64/sve2p1-intrinsics-fclamp.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/AArch64/sve2p1-intrinsics-fclamp.ll @@ -0,0 +1,37 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -verify-machineinstrs < %s | FileCheck %s + +target triple = "aarch64-linux-gnu" + +define @test_fclamp_f16( %a, %b, %c) #0 { +; CHECK-LABEL: test_fclamp_f16: +; CHECK: // %bb.0: +; CHECK-NEXT: fclamp z0.h, z1.h, z2.h +; CHECK-NEXT: ret + %res = call @llvm.aarch64.sve.fclamp.nxv8f16( %a, %b, %c) + ret %res +} + +define @test_fclamp_f32( %a, %b, %c) #0 { +; CHECK-LABEL: test_fclamp_f32: +; CHECK: // %bb.0: +; CHECK-NEXT: fclamp z0.s, z1.s, z2.s +; CHECK-NEXT: ret + %res = call @llvm.aarch64.sve.fclamp.nxv4f32( %a, %b, %c) + ret %res +} + +define @test_fclamp_f64( %a, %b, %c) #0 { +; CHECK-LABEL: test_fclamp_f64: +; CHECK: // %bb.0: +; CHECK-NEXT: fclamp z0.d, z1.d, z2.d +; CHECK-NEXT: ret + %res = call @llvm.aarch64.sve.fclamp.nxv2f64( %a, %b, %c) + ret %res +} + +attributes #0 = { "target-features"="+sve2p1" } + +declare @llvm.aarch64.sve.fclamp.nxv8f16(, , ) +declare @llvm.aarch64.sve.fclamp.nxv4f32(, , ) +declare @llvm.aarch64.sve.fclamp.nxv2f64(, , )