diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 0fb02141801..6e739d8df6a 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -44,6 +44,19 @@ def int_aarch64_fjcvtzs : DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_double_ty], def int_aarch64_cls: DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrNoMem]>; def int_aarch64_cls64: DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i64_ty], [IntrNoMem]>; +def int_aarch64_frint32z + : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], [ LLVMMatchType<0> ], + [ IntrNoMem ]>; +def int_aarch64_frint64z + : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], [ LLVMMatchType<0> ], + [ IntrNoMem ]>; +def int_aarch64_frint32x + : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], [ LLVMMatchType<0> ], + [ IntrNoMem ]>; +def int_aarch64_frint64x + : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], [ LLVMMatchType<0> ], + [ IntrNoMem ]>; + //===----------------------------------------------------------------------===// // HINT diff --git a/lib/Target/AArch64/AArch64InstrInfo.td b/lib/Target/AArch64/AArch64InstrInfo.td index e9f294028a2..89c7234485f 100644 --- a/lib/Target/AArch64/AArch64InstrInfo.td +++ b/lib/Target/AArch64/AArch64InstrInfo.td @@ -3805,10 +3805,10 @@ defm FSQRT : SingleOperandFPData<0b0011, "fsqrt", fsqrt>; } let Predicates = [HasFRInt3264] in { - defm FRINT32Z : FRIntNNT<0b00, "frint32z">; - defm FRINT64Z : FRIntNNT<0b10, "frint64z">; - defm FRINT32X : FRIntNNT<0b01, "frint32x">; - defm FRINT64X : FRIntNNT<0b11, "frint64x">; + defm FRINT32Z : FRIntNNT<0b00, "frint32z", int_aarch64_frint32z>; + defm FRINT64Z : FRIntNNT<0b10, "frint64z", int_aarch64_frint64z>; + defm FRINT32X : FRIntNNT<0b01, "frint32x", int_aarch64_frint32x>; + defm FRINT64X : FRIntNNT<0b11, "frint64x", int_aarch64_frint64x>; } // HasFRInt3264 let Predicates = [HasFullFP16] in { diff --git a/test/CodeGen/AArch64/v8.5a-scalar-frint3264-intrinsic.ll b/test/CodeGen/AArch64/v8.5a-scalar-frint3264-intrinsic.ll new file mode 100644 index 00000000000..b4a0f3d557c --- /dev/null +++ b/test/CodeGen/AArch64/v8.5a-scalar-frint3264-intrinsic.ll @@ -0,0 +1,83 @@ +; RUN: llc < %s -mtriple=aarch64-eabi -mattr=+v8.5a | FileCheck %s + +declare float @llvm.aarch64.frint32z.f32(float) +declare double @llvm.aarch64.frint32z.f64(double) +declare float @llvm.aarch64.frint64z.f32(float) +declare double @llvm.aarch64.frint64z.f64(double) + +define dso_local float @t_frint32z(float %a) { +; CHECK-LABEL: t_frint32z: +; CHECK: frint32z s0, s0 +; CHECK-NEXT: ret +entry: + %val = tail call float @llvm.aarch64.frint32z.f32(float %a) + ret float %val +} + +define dso_local double @t_frint32zf(double %a) { +; CHECK-LABEL: t_frint32zf: +; CHECK: frint32z d0, d0 +; CHECK-NEXT: ret +entry: + %val = tail call double @llvm.aarch64.frint32z.f64(double %a) + ret double %val +} + +define dso_local float @t_frint64z(float %a) { +; CHECK-LABEL: t_frint64z: +; CHECK: frint64z s0, s0 +; CHECK-NEXT: ret +entry: + %val = tail call float @llvm.aarch64.frint64z.f32(float %a) + ret float %val +} + +define dso_local double @t_frint64zf(double %a) { +; CHECK-LABEL: t_frint64zf: +; CHECK: frint64z d0, d0 +; CHECK-NEXT: ret +entry: + %val = tail call double @llvm.aarch64.frint64z.f64(double %a) + ret double %val +} + +declare float @llvm.aarch64.frint32x.f32(float) +declare double @llvm.aarch64.frint32x.f64(double) +declare float @llvm.aarch64.frint64x.f32(float) +declare double @llvm.aarch64.frint64x.f64(double) + +define dso_local float @t_frint32x(float %a) { +; CHECK-LABEL: t_frint32x: +; CHECK: frint32x s0, s0 +; CHECK-NEXT: ret +entry: + %val = tail call float @llvm.aarch64.frint32x.f32(float %a) + ret float %val +} + +define dso_local double @t_frint32xf(double %a) { +; CHECK-LABEL: t_frint32xf: +; CHECK: frint32x d0, d0 +; CHECK-NEXT: ret +entry: + %val = tail call double @llvm.aarch64.frint32x.f64(double %a) + ret double %val +} + +define dso_local float @t_frint64x(float %a) { +; CHECK-LABEL: t_frint64x: +; CHECK: frint64x s0, s0 +; CHECK-NEXT: ret +entry: + %val = tail call float @llvm.aarch64.frint64x.f32(float %a) + ret float %val +} + +define dso_local double @t_frint64xf(double %a) { +; CHECK-LABEL: t_frint64xf: +; CHECK: frint64x d0, d0 +; CHECK-NEXT: ret +entry: + %val = tail call double @llvm.aarch64.frint64x.f64(double %a) + ret double %val +}