[llvm] [RISCV][GISel] Add ZFA FP legalization and full tests for 9 insn (PR #118723)
Luke Quinn via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 4 18:34:34 PST 2024
https://github.com/lquinn2015 updated https://github.com/llvm/llvm-project/pull/118723
>From 892e94c15ecb46fb78aae45c470eba56583f06e3 Mon Sep 17 00:00:00 2001
From: Luke Quinn <quic_lquinn at quicinc.com>
Date: Wed, 4 Dec 2024 17:38:14 -0800
Subject: [PATCH 1/3] [WIP][RISCV][GISel] Add ZFA 7 insn [WIP] (min/max)imum
Signed-off-by: Luke Quinn <quic_lquinn at quicinc.com>
---
.../Target/RISCV/GISel/RISCVLegalizerInfo.cpp | 6 +-
.../CodeGen/RISCV/GlobalISel/double-zfa.ll | 160 +++++++++++++++++
.../CodeGen/RISCV/GlobalISel/float-zfa.ll | 161 ++++++++++++++++++
.../test/CodeGen/RISCV/GlobalISel/half-zfa.ll | 78 +++++++++
4 files changed, 403 insertions(+), 2 deletions(-)
create mode 100644 llvm/test/CodeGen/RISCV/GlobalISel/double-zfa.ll
create mode 100644 llvm/test/CodeGen/RISCV/GlobalISel/float-zfa.ll
create mode 100644 llvm/test/CodeGen/RISCV/GlobalISel/half-zfa.ll
diff --git a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
index 456ca9894e6a7d..fcf88be2d0782b 100644
--- a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
+++ b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
@@ -582,10 +582,12 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
.libcallFor(ST.is64Bit(), {{s32, s128}, {s64, s128}});
// FIXME: We can do custom inline expansion like SelectionDAG.
- // FIXME: Legal with Zfa.
getActionDefinitionsBuilder({G_FCEIL, G_FFLOOR, G_FRINT, G_FNEARBYINT,
G_INTRINSIC_TRUNC, G_INTRINSIC_ROUND,
- G_INTRINSIC_ROUNDEVEN})
+ G_INTRINSIC_ROUNDEVEN, G_FMAXIMUM, G_FMINIMUM})
+ .legalFor(ST.hasStdExtZfa() /*ST.hasStdExtF()*/, {s32})
+ .legalFor(ST.hasStdExtZfa() && ST.hasStdExtD(), {s64})
+ .legalFor(ST.hasStdExtZfa() && ST.hasStdExtZfh(), {s16})
.libcallFor({s32, s64});
getActionDefinitionsBuilder({G_FCOS, G_FSIN, G_FTAN, G_FPOW, G_FLOG, G_FLOG2,
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/double-zfa.ll b/llvm/test/CodeGen/RISCV/GlobalISel/double-zfa.ll
new file mode 100644
index 00000000000000..03f3e27bfc4996
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/double-zfa.ll
@@ -0,0 +1,160 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+
+; RUN: llc -mtriple=riscv32 -mattr=+zfa,d -global-isel < %s \
+; RUN: | FileCheck %s --check-prefixes=CHECK-ZFA-f64
+; RUN: llc -mtriple=riscv64 -mattr=+zfa,d -global-isel < %s \
+; RUN: | FileCheck %s --check-prefixes=CHECK-ZFA-f64
+; RUN: llc -mtriple=riscv32 -mattr=+d -global-isel < %s \
+; RUN: | FileCheck %s --check-prefix=CHECK-ZFA-libcall
+
+
+define double @fceil(double %a) {
+; CHECK-ZFA-f64-LABEL: fceil:
+; CHECK-ZFA-f64: # %bb.0:
+; CHECK-ZFA-f64-NEXT: fround.d fa0, fa0, rup
+; CHECK-ZFA-f64-NEXT: ret
+;
+; CHECK-ZFA-libcall-LABEL: fceil:
+; CHECK-ZFA-libcall: # %bb.0:
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
+; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
+; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
+; CHECK-ZFA-libcall-NEXT: call ceil
+; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
+; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
+; CHECK-ZFA-libcall-NEXT: ret
+ %b = call double @llvm.ceil.f64(double %a)
+ ret double %b
+}
+
+define double @ffloor(double %a) {
+; CHECK-ZFA-f64-LABEL: ffloor:
+; CHECK-ZFA-f64: # %bb.0:
+; CHECK-ZFA-f64-NEXT: fround.d fa0, fa0, rdn
+; CHECK-ZFA-f64-NEXT: ret
+;
+; CHECK-ZFA-libcall-LABEL: ffloor:
+; CHECK-ZFA-libcall: # %bb.0:
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
+; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
+; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
+; CHECK-ZFA-libcall-NEXT: call floor
+; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
+; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
+; CHECK-ZFA-libcall-NEXT: ret
+ %b = call double @llvm.floor.f64(double %a)
+ ret double %b
+}
+
+define double @frint(double %a) {
+; CHECK-ZFA-f64-LABEL: frint:
+; CHECK-ZFA-f64: # %bb.0:
+; CHECK-ZFA-f64-NEXT: froundnx.d fa0, fa0
+; CHECK-ZFA-f64-NEXT: ret
+;
+; CHECK-ZFA-libcall-LABEL: frint:
+; CHECK-ZFA-libcall: # %bb.0:
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
+; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
+; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
+; CHECK-ZFA-libcall-NEXT: call rint
+; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
+; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
+; CHECK-ZFA-libcall-NEXT: ret
+ %b = call double @llvm.rint.f64(double %a)
+ ret double %b
+}
+
+define double @fnearbyint(double %a) {
+; CHECK-ZFA-f64-LABEL: fnearbyint:
+; CHECK-ZFA-f64: # %bb.0:
+; CHECK-ZFA-f64-NEXT: fround.d fa0, fa0
+; CHECK-ZFA-f64-NEXT: ret
+;
+; CHECK-ZFA-libcall-LABEL: fnearbyint:
+; CHECK-ZFA-libcall: # %bb.0:
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
+; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
+; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
+; CHECK-ZFA-libcall-NEXT: call nearbyint
+; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
+; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
+; CHECK-ZFA-libcall-NEXT: ret
+ %b = call double @llvm.nearbyint.f64(double %a)
+ ret double %b
+}
+
+define double @fround(double %a) {
+; CHECK-ZFA-f64-LABEL: fround:
+; CHECK-ZFA-f64: # %bb.0:
+; CHECK-ZFA-f64-NEXT: fround.d fa0, fa0, rmm
+; CHECK-ZFA-f64-NEXT: ret
+;
+; CHECK-ZFA-libcall-LABEL: fround:
+; CHECK-ZFA-libcall: # %bb.0:
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
+; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
+; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
+; CHECK-ZFA-libcall-NEXT: call round
+; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
+; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
+; CHECK-ZFA-libcall-NEXT: ret
+ %b = call double @llvm.round.f64(double %a)
+ ret double %b
+}
+
+define double @froundeven(double %a) {
+; CHECK-ZFA-f64-LABEL: froundeven:
+; CHECK-ZFA-f64: # %bb.0:
+; CHECK-ZFA-f64-NEXT: fround.d fa0, fa0, rne
+; CHECK-ZFA-f64-NEXT: ret
+;
+; CHECK-ZFA-libcall-LABEL: froundeven:
+; CHECK-ZFA-libcall: # %bb.0:
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
+; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
+; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
+; CHECK-ZFA-libcall-NEXT: call roundeven
+; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
+; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
+; CHECK-ZFA-libcall-NEXT: ret
+ %b = call double @llvm.roundeven.f64(double %a)
+ ret double %b
+}
+
+;; TODO recreate this test with LIB call
+;define double @fmaximum(double %a, double %b) {
+;; CHECK-ZFA-f64-LABEL: fmaximum:
+;; CHECK-ZFA-f64: # %bb.0:
+;; CHECK-ZFA-f64-NEXT: fmaxm.d fa0, fa0, fa1
+;; CHECK-ZFA-f64-NEXT: ret
+; %c = call double @llvm.maximum.f64(double %a, double %b)
+; ret double %c
+;}
+;
+;define double @fminimum(double %a, double %b) {
+;; CHECK-ZFA-f64-LABEL: fminimum:
+;; CHECK-ZFA-f64: # %bb.0:
+;; CHECK-ZFA-f64-NEXT: fminm.d fa0, fa0, fa1
+;; CHECK-ZFA-f64-NEXT: ret
+; %c = call double @llvm.minimum.f64(double %a, double %b)
+; ret double %c
+;}
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/float-zfa.ll b/llvm/test/CodeGen/RISCV/GlobalISel/float-zfa.ll
new file mode 100644
index 00000000000000..6ec17e6b7b76bc
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/float-zfa.ll
@@ -0,0 +1,161 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+
+; RUN: llc -mtriple=riscv32 -mattr=+zfa -global-isel < %s \
+; RUN: | FileCheck %s --check-prefixes=CHECK-ZFA-f32
+; RUN: llc -mtriple=riscv64 -mattr=+zfa -global-isel < %s \
+; RUN: | FileCheck %s --check-prefixes=CHECK-ZFA-f32
+; RUN: llc -mtriple=riscv32 -mattr=+f -global-isel < %s \
+; RUN: | FileCheck %s --check-prefix=CHECK-ZFA-libcall
+
+
+define float @fceil(float %a) {
+; CHECK-ZFA-f32-LABEL: fceil:
+; CHECK-ZFA-f32: # %bb.0:
+; CHECK-ZFA-f32-NEXT: fround.s fa0, fa0, rup
+; CHECK-ZFA-f32-NEXT: ret
+;
+; CHECK-ZFA-libcall-LABEL: fceil:
+; CHECK-ZFA-libcall: # %bb.0:
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
+; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
+; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
+; CHECK-ZFA-libcall-NEXT: call ceilf
+; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
+; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
+; CHECK-ZFA-libcall-NEXT: ret
+ %b = call float @llvm.ceil.f32(float %a)
+ ret float %b
+}
+
+define float @ffloor(float %a) {
+; CHECK-ZFA-f32-LABEL: ffloor:
+; CHECK-ZFA-f32: # %bb.0:
+; CHECK-ZFA-f32-NEXT: fround.s fa0, fa0, rdn
+; CHECK-ZFA-f32-NEXT: ret
+;
+; CHECK-ZFA-libcall-LABEL: ffloor:
+; CHECK-ZFA-libcall: # %bb.0:
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
+; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
+; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
+; CHECK-ZFA-libcall-NEXT: call floorf
+; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
+; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
+; CHECK-ZFA-libcall-NEXT: ret
+ %b = call float @llvm.floor.f32(float %a)
+ ret float %b
+}
+
+define float @frint(float %a) {
+; CHECK-ZFA-f32-LABEL: frint:
+; CHECK-ZFA-f32: # %bb.0:
+; CHECK-ZFA-f32-NEXT: froundnx.s fa0, fa0
+; CHECK-ZFA-f32-NEXT: ret
+;
+; CHECK-ZFA-libcall-LABEL: frint:
+; CHECK-ZFA-libcall: # %bb.0:
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
+; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
+; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
+; CHECK-ZFA-libcall-NEXT: call rintf
+; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
+; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
+; CHECK-ZFA-libcall-NEXT: ret
+ %b = call float @llvm.rint.f32(float %a)
+ ret float %b
+}
+
+define float @fnearbyint(float %a) {
+; CHECK-ZFA-f32-LABEL: fnearbyint:
+; CHECK-ZFA-f32: # %bb.0:
+; CHECK-ZFA-f32-NEXT: fround.s fa0, fa0
+; CHECK-ZFA-f32-NEXT: ret
+;
+; CHECK-ZFA-libcall-LABEL: fnearbyint:
+; CHECK-ZFA-libcall: # %bb.0:
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
+; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
+; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
+; CHECK-ZFA-libcall-NEXT: call nearbyintf
+; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
+; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
+; CHECK-ZFA-libcall-NEXT: ret
+ %b = call float @llvm.nearbyint.f32(float %a)
+ ret float %b
+}
+
+define float @fround(float %a) {
+; CHECK-ZFA-f32-LABEL: fround:
+; CHECK-ZFA-f32: # %bb.0:
+; CHECK-ZFA-f32-NEXT: fround.s fa0, fa0, rmm
+; CHECK-ZFA-f32-NEXT: ret
+;
+; CHECK-ZFA-libcall-LABEL: fround:
+; CHECK-ZFA-libcall: # %bb.0:
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
+; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
+; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
+; CHECK-ZFA-libcall-NEXT: call roundf
+; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
+; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
+; CHECK-ZFA-libcall-NEXT: ret
+ %b = call float @llvm.round.f32(float %a)
+ ret float %b
+}
+
+
+define float @froundeven(float %a) {
+; CHECK-ZFA-f32-LABEL: froundeven:
+; CHECK-ZFA-f32: # %bb.0:
+; CHECK-ZFA-f32-NEXT: fround.s fa0, fa0, rne
+; CHECK-ZFA-f32-NEXT: ret
+;
+; CHECK-ZFA-libcall-LABEL: froundeven:
+; CHECK-ZFA-libcall: # %bb.0:
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
+; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
+; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
+; CHECK-ZFA-libcall-NEXT: call roundevenf
+; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
+; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
+; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
+; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
+; CHECK-ZFA-libcall-NEXT: ret
+ %b = call float @llvm.roundeven.f32(float %a)
+ ret float %b
+}
+
+; TODO fix these tests for libcall
+;;define float @fmaximum(float %a, float %b) {
+;; CHECK-ZFA-f32-LABEL: fmaximum:
+;; CHECK-ZFA-f32: # %bb.0:
+;; CHECK-ZFA-f32-NEXT: fmaxm.s fa0, fa0, fa1
+;; CHECK-ZFA-f32-NEXT: ret
+; %c = call float @llvm.maximum.f32(float %a, float %b)
+; ret float %c
+;}
+;
+;define float @fminimum(float %a, float %b) {
+;; CHECK-ZFA-f32-LABEL: fminimum:
+;; CHECK-ZFA-f32: # %bb.0:
+;; CHECK-ZFA-f32-NEXT: fminm.s fa0, fa0, fa1
+;; CHECK-ZFA-f32-NEXT: ret
+; %c = call float @llvm.minimum.f32(float %a, float %b)
+; ret float %c
+;}
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/half-zfa.ll b/llvm/test/CodeGen/RISCV/GlobalISel/half-zfa.ll
new file mode 100644
index 00000000000000..7e8d6d8758c5e8
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/half-zfa.ll
@@ -0,0 +1,78 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+
+; RUN: llc -mtriple=riscv32 -mattr=+zfa,+zfh -global-isel < %s \
+; RUN: | FileCheck %s --check-prefixes=CHECK-ZFA-f16
+; RUN: llc -mtriple=riscv64 -mattr=+zfa,+zfh -global-isel < %s \
+; RUN: | FileCheck %s --check-prefixes=CHECK-ZFA-f16
+
+
+define half @fceil(half %a) {
+; CHECK-ZFA-f16-LABEL: fceil:
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rup
+; CHECK-ZFA-f16-NEXT: ret
+ %b = call half @llvm.ceil.f16(half %a)
+ ret half %b
+}
+
+define half @ffloor(half %a) {
+; CHECK-ZFA-f16-LABEL: ffloor:
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rdn
+; CHECK-ZFA-f16-NEXT: ret
+ %b = call half @llvm.floor.f16(half %a)
+ ret half %b
+}
+
+define half @frint(half %a) {
+; CHECK-ZFA-f16-LABEL: frint:
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: froundnx.h fa0, fa0
+; CHECK-ZFA-f16-NEXT: ret
+ %b = call half @llvm.rint.f16(half %a)
+ ret half %b
+}
+
+define half @fnearbyint(half %a) {
+; CHECK-ZFA-f16-LABEL: fnearbyint:
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0
+; CHECK-ZFA-f16-NEXT: ret
+ %b = call half @llvm.nearbyint.f16(half %a)
+ ret half %b
+}
+
+define half @fround(half %a) {
+; CHECK-ZFA-f16-LABEL: fround:
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rmm
+; CHECK-ZFA-f16-NEXT: ret
+ %b = call half @llvm.round.f16(half %a)
+ ret half %b
+}
+
+define half @froundeven(half %a) {
+; CHECK-ZFA-f16-LABEL: froundeven:
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rne
+; CHECK-ZFA-f16-NEXT: ret
+ %b = call half @llvm.roundeven.f16(half %a)
+ ret half %b
+}
+define half @fmaximum(half %a, half %b) {
+; CHECK-ZFA-f16-LABEL: fmaximum:
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fmaxm.h fa0, fa0, fa1
+; CHECK-ZFA-f16-NEXT: ret
+ %c = call half @llvm.maximum.f16(half %a, half %b)
+ ret half %c
+}
+
+define half @fminimum(half %a, half %b) {
+; CHECK-ZFA-f16-LABEL: fminimum:
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fminm.h fa0, fa0, fa1
+; CHECK-ZFA-f16-NEXT: ret
+ %c = call half @llvm.minimum.f16(half %a, half %b)
+ ret half %c
+}
>From b7c6ce1101a7ac65ca6dc24106dbd4df88739ae1 Mon Sep 17 00:00:00 2001
From: Luke Quinn <quic_lquinn at quicinc.com>
Date: Wed, 4 Dec 2024 17:40:14 -0800
Subject: [PATCH 2/3] [WIP][rebase] Spacing fix for half
Signed-off-by: Luke Quinn <quic_lquinn at quicinc.com>
---
.../test/CodeGen/RISCV/GlobalISel/half-zfa.ll | 80 +++++++++----------
1 file changed, 40 insertions(+), 40 deletions(-)
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/half-zfa.ll b/llvm/test/CodeGen/RISCV/GlobalISel/half-zfa.ll
index 7e8d6d8758c5e8..5d907063354c41 100644
--- a/llvm/test/CodeGen/RISCV/GlobalISel/half-zfa.ll
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/half-zfa.ll
@@ -8,71 +8,71 @@
define half @fceil(half %a) {
; CHECK-ZFA-f16-LABEL: fceil:
-; CHECK-ZFA-f16: # %bb.0:
-; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rup
-; CHECK-ZFA-f16-NEXT: ret
- %b = call half @llvm.ceil.f16(half %a)
- ret half %b
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rup
+; CHECK-ZFA-f16-NEXT: ret
+ %b = call half @llvm.ceil.f16(half %a)
+ ret half %b
}
define half @ffloor(half %a) {
; CHECK-ZFA-f16-LABEL: ffloor:
-; CHECK-ZFA-f16: # %bb.0:
-; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rdn
-; CHECK-ZFA-f16-NEXT: ret
- %b = call half @llvm.floor.f16(half %a)
- ret half %b
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rdn
+; CHECK-ZFA-f16-NEXT: ret
+ %b = call half @llvm.floor.f16(half %a)
+ ret half %b
}
define half @frint(half %a) {
; CHECK-ZFA-f16-LABEL: frint:
-; CHECK-ZFA-f16: # %bb.0:
-; CHECK-ZFA-f16-NEXT: froundnx.h fa0, fa0
-; CHECK-ZFA-f16-NEXT: ret
- %b = call half @llvm.rint.f16(half %a)
- ret half %b
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: froundnx.h fa0, fa0
+; CHECK-ZFA-f16-NEXT: ret
+ %b = call half @llvm.rint.f16(half %a)
+ ret half %b
}
define half @fnearbyint(half %a) {
; CHECK-ZFA-f16-LABEL: fnearbyint:
-; CHECK-ZFA-f16: # %bb.0:
-; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0
-; CHECK-ZFA-f16-NEXT: ret
- %b = call half @llvm.nearbyint.f16(half %a)
- ret half %b
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0
+; CHECK-ZFA-f16-NEXT: ret
+ %b = call half @llvm.nearbyint.f16(half %a)
+ ret half %b
}
define half @fround(half %a) {
; CHECK-ZFA-f16-LABEL: fround:
-; CHECK-ZFA-f16: # %bb.0:
-; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rmm
-; CHECK-ZFA-f16-NEXT: ret
- %b = call half @llvm.round.f16(half %a)
- ret half %b
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rmm
+; CHECK-ZFA-f16-NEXT: ret
+ %b = call half @llvm.round.f16(half %a)
+ ret half %b
}
define half @froundeven(half %a) {
; CHECK-ZFA-f16-LABEL: froundeven:
-; CHECK-ZFA-f16: # %bb.0:
-; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rne
-; CHECK-ZFA-f16-NEXT: ret
- %b = call half @llvm.roundeven.f16(half %a)
- ret half %b
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rne
+; CHECK-ZFA-f16-NEXT: ret
+ %b = call half @llvm.roundeven.f16(half %a)
+ ret half %b
}
define half @fmaximum(half %a, half %b) {
; CHECK-ZFA-f16-LABEL: fmaximum:
-; CHECK-ZFA-f16: # %bb.0:
-; CHECK-ZFA-f16-NEXT: fmaxm.h fa0, fa0, fa1
-; CHECK-ZFA-f16-NEXT: ret
- %c = call half @llvm.maximum.f16(half %a, half %b)
- ret half %c
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fmaxm.h fa0, fa0, fa1
+; CHECK-ZFA-f16-NEXT: ret
+ %c = call half @llvm.maximum.f16(half %a, half %b)
+ ret half %c
}
define half @fminimum(half %a, half %b) {
; CHECK-ZFA-f16-LABEL: fminimum:
-; CHECK-ZFA-f16: # %bb.0:
-; CHECK-ZFA-f16-NEXT: fminm.h fa0, fa0, fa1
-; CHECK-ZFA-f16-NEXT: ret
- %c = call half @llvm.minimum.f16(half %a, half %b)
- ret half %c
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fminm.h fa0, fa0, fa1
+; CHECK-ZFA-f16-NEXT: ret
+ %c = call half @llvm.minimum.f16(half %a, half %b)
+ ret half %c
}
>From 8670e42d86e57879a1e940767a44e16ebf3b46ee Mon Sep 17 00:00:00 2001
From: Luke Quinn <quic_lquinn at quicinc.com>
Date: Wed, 4 Dec 2024 18:34:17 -0800
Subject: [PATCH 3/3] [WIP] this fixes most things but I am failing coverage on
G_FMINIMUM and G_MAXIMUM in the mir validation script
Signed-off-by: Luke Quinn <quic_lquinn at quicinc.com>
---
.../Target/RISCV/GISel/RISCVLegalizerInfo.cpp | 8 +-
.../CodeGen/RISCV/GlobalISel/double-zfa.ll | 115 +++---------------
.../CodeGen/RISCV/GlobalISel/float-zfa.ll | 115 +++---------------
.../test/CodeGen/RISCV/GlobalISel/half-zfa.ll | 48 ++++----
4 files changed, 65 insertions(+), 221 deletions(-)
diff --git a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
index fcf88be2d0782b..ad9bf513da2743 100644
--- a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
+++ b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
@@ -584,11 +584,17 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
// FIXME: We can do custom inline expansion like SelectionDAG.
getActionDefinitionsBuilder({G_FCEIL, G_FFLOOR, G_FRINT, G_FNEARBYINT,
G_INTRINSIC_TRUNC, G_INTRINSIC_ROUND,
- G_INTRINSIC_ROUNDEVEN, G_FMAXIMUM, G_FMINIMUM})
+ G_INTRINSIC_ROUNDEVEN})
.legalFor(ST.hasStdExtZfa() /*ST.hasStdExtF()*/, {s32})
.legalFor(ST.hasStdExtZfa() && ST.hasStdExtD(), {s64})
.legalFor(ST.hasStdExtZfa() && ST.hasStdExtZfh(), {s16})
.libcallFor({s32, s64});
+
+ getActionDefinitionsBuilder({G_FMAXIMUM, G_FMINIMUM})
+ .legalFor(ST.hasStdExtZfa() /*ST.hasStdExtF()*/, {s32})
+ .legalFor(ST.hasStdExtZfa() && ST.hasStdExtD(), {s64})
+ .legalFor(ST.hasStdExtZfa() && ST.hasStdExtZfh(), {s16});
+
getActionDefinitionsBuilder({G_FCOS, G_FSIN, G_FTAN, G_FPOW, G_FLOG, G_FLOG2,
G_FLOG10, G_FEXP, G_FEXP2, G_FEXP10, G_FACOS,
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/double-zfa.ll b/llvm/test/CodeGen/RISCV/GlobalISel/double-zfa.ll
index 03f3e27bfc4996..53184c885e9886 100644
--- a/llvm/test/CodeGen/RISCV/GlobalISel/double-zfa.ll
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/double-zfa.ll
@@ -4,8 +4,6 @@
; RUN: | FileCheck %s --check-prefixes=CHECK-ZFA-f64
; RUN: llc -mtriple=riscv64 -mattr=+zfa,d -global-isel < %s \
; RUN: | FileCheck %s --check-prefixes=CHECK-ZFA-f64
-; RUN: llc -mtriple=riscv32 -mattr=+d -global-isel < %s \
-; RUN: | FileCheck %s --check-prefix=CHECK-ZFA-libcall
define double @fceil(double %a) {
@@ -13,19 +11,6 @@ define double @fceil(double %a) {
; CHECK-ZFA-f64: # %bb.0:
; CHECK-ZFA-f64-NEXT: fround.d fa0, fa0, rup
; CHECK-ZFA-f64-NEXT: ret
-;
-; CHECK-ZFA-libcall-LABEL: fceil:
-; CHECK-ZFA-libcall: # %bb.0:
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
-; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
-; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
-; CHECK-ZFA-libcall-NEXT: call ceil
-; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
-; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
-; CHECK-ZFA-libcall-NEXT: ret
%b = call double @llvm.ceil.f64(double %a)
ret double %b
}
@@ -35,19 +20,6 @@ define double @ffloor(double %a) {
; CHECK-ZFA-f64: # %bb.0:
; CHECK-ZFA-f64-NEXT: fround.d fa0, fa0, rdn
; CHECK-ZFA-f64-NEXT: ret
-;
-; CHECK-ZFA-libcall-LABEL: ffloor:
-; CHECK-ZFA-libcall: # %bb.0:
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
-; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
-; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
-; CHECK-ZFA-libcall-NEXT: call floor
-; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
-; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
-; CHECK-ZFA-libcall-NEXT: ret
%b = call double @llvm.floor.f64(double %a)
ret double %b
}
@@ -57,19 +29,6 @@ define double @frint(double %a) {
; CHECK-ZFA-f64: # %bb.0:
; CHECK-ZFA-f64-NEXT: froundnx.d fa0, fa0
; CHECK-ZFA-f64-NEXT: ret
-;
-; CHECK-ZFA-libcall-LABEL: frint:
-; CHECK-ZFA-libcall: # %bb.0:
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
-; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
-; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
-; CHECK-ZFA-libcall-NEXT: call rint
-; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
-; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
-; CHECK-ZFA-libcall-NEXT: ret
%b = call double @llvm.rint.f64(double %a)
ret double %b
}
@@ -79,19 +38,6 @@ define double @fnearbyint(double %a) {
; CHECK-ZFA-f64: # %bb.0:
; CHECK-ZFA-f64-NEXT: fround.d fa0, fa0
; CHECK-ZFA-f64-NEXT: ret
-;
-; CHECK-ZFA-libcall-LABEL: fnearbyint:
-; CHECK-ZFA-libcall: # %bb.0:
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
-; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
-; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
-; CHECK-ZFA-libcall-NEXT: call nearbyint
-; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
-; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
-; CHECK-ZFA-libcall-NEXT: ret
%b = call double @llvm.nearbyint.f64(double %a)
ret double %b
}
@@ -101,19 +47,6 @@ define double @fround(double %a) {
; CHECK-ZFA-f64: # %bb.0:
; CHECK-ZFA-f64-NEXT: fround.d fa0, fa0, rmm
; CHECK-ZFA-f64-NEXT: ret
-;
-; CHECK-ZFA-libcall-LABEL: fround:
-; CHECK-ZFA-libcall: # %bb.0:
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
-; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
-; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
-; CHECK-ZFA-libcall-NEXT: call round
-; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
-; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
-; CHECK-ZFA-libcall-NEXT: ret
%b = call double @llvm.round.f64(double %a)
ret double %b
}
@@ -123,38 +56,24 @@ define double @froundeven(double %a) {
; CHECK-ZFA-f64: # %bb.0:
; CHECK-ZFA-f64-NEXT: fround.d fa0, fa0, rne
; CHECK-ZFA-f64-NEXT: ret
-;
-; CHECK-ZFA-libcall-LABEL: froundeven:
-; CHECK-ZFA-libcall: # %bb.0:
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
-; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
-; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
-; CHECK-ZFA-libcall-NEXT: call roundeven
-; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
-; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
-; CHECK-ZFA-libcall-NEXT: ret
%b = call double @llvm.roundeven.f64(double %a)
ret double %b
}
-;; TODO recreate this test with LIB call
-;define double @fmaximum(double %a, double %b) {
-;; CHECK-ZFA-f64-LABEL: fmaximum:
-;; CHECK-ZFA-f64: # %bb.0:
-;; CHECK-ZFA-f64-NEXT: fmaxm.d fa0, fa0, fa1
-;; CHECK-ZFA-f64-NEXT: ret
-; %c = call double @llvm.maximum.f64(double %a, double %b)
-; ret double %c
-;}
-;
-;define double @fminimum(double %a, double %b) {
-;; CHECK-ZFA-f64-LABEL: fminimum:
-;; CHECK-ZFA-f64: # %bb.0:
-;; CHECK-ZFA-f64-NEXT: fminm.d fa0, fa0, fa1
-;; CHECK-ZFA-f64-NEXT: ret
-; %c = call double @llvm.minimum.f64(double %a, double %b)
-; ret double %c
-;}
+define double @fmaximum(double %a, double %b) {
+; CHECK-ZFA-f64-LABEL: fmaximum:
+; CHECK-ZFA-f64: # %bb.0:
+; CHECK-ZFA-f64-NEXT: fmaxm.d fa0, fa0, fa1
+; CHECK-ZFA-f64-NEXT: ret
+ %c = call double @llvm.maximum.f64(double %a, double %b)
+ ret double %c
+}
+
+define double @fminimum(double %a, double %b) {
+; CHECK-ZFA-f64-LABEL: fminimum:
+; CHECK-ZFA-f64: # %bb.0:
+; CHECK-ZFA-f64-NEXT: fminm.d fa0, fa0, fa1
+; CHECK-ZFA-f64-NEXT: ret
+ %c = call double @llvm.minimum.f64(double %a, double %b)
+ ret double %c
+}
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/float-zfa.ll b/llvm/test/CodeGen/RISCV/GlobalISel/float-zfa.ll
index 6ec17e6b7b76bc..697628455f75a0 100644
--- a/llvm/test/CodeGen/RISCV/GlobalISel/float-zfa.ll
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/float-zfa.ll
@@ -4,8 +4,6 @@
; RUN: | FileCheck %s --check-prefixes=CHECK-ZFA-f32
; RUN: llc -mtriple=riscv64 -mattr=+zfa -global-isel < %s \
; RUN: | FileCheck %s --check-prefixes=CHECK-ZFA-f32
-; RUN: llc -mtriple=riscv32 -mattr=+f -global-isel < %s \
-; RUN: | FileCheck %s --check-prefix=CHECK-ZFA-libcall
define float @fceil(float %a) {
@@ -13,19 +11,6 @@ define float @fceil(float %a) {
; CHECK-ZFA-f32: # %bb.0:
; CHECK-ZFA-f32-NEXT: fround.s fa0, fa0, rup
; CHECK-ZFA-f32-NEXT: ret
-;
-; CHECK-ZFA-libcall-LABEL: fceil:
-; CHECK-ZFA-libcall: # %bb.0:
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
-; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
-; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
-; CHECK-ZFA-libcall-NEXT: call ceilf
-; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
-; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
-; CHECK-ZFA-libcall-NEXT: ret
%b = call float @llvm.ceil.f32(float %a)
ret float %b
}
@@ -35,19 +20,6 @@ define float @ffloor(float %a) {
; CHECK-ZFA-f32: # %bb.0:
; CHECK-ZFA-f32-NEXT: fround.s fa0, fa0, rdn
; CHECK-ZFA-f32-NEXT: ret
-;
-; CHECK-ZFA-libcall-LABEL: ffloor:
-; CHECK-ZFA-libcall: # %bb.0:
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
-; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
-; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
-; CHECK-ZFA-libcall-NEXT: call floorf
-; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
-; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
-; CHECK-ZFA-libcall-NEXT: ret
%b = call float @llvm.floor.f32(float %a)
ret float %b
}
@@ -57,19 +29,6 @@ define float @frint(float %a) {
; CHECK-ZFA-f32: # %bb.0:
; CHECK-ZFA-f32-NEXT: froundnx.s fa0, fa0
; CHECK-ZFA-f32-NEXT: ret
-;
-; CHECK-ZFA-libcall-LABEL: frint:
-; CHECK-ZFA-libcall: # %bb.0:
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
-; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
-; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
-; CHECK-ZFA-libcall-NEXT: call rintf
-; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
-; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
-; CHECK-ZFA-libcall-NEXT: ret
%b = call float @llvm.rint.f32(float %a)
ret float %b
}
@@ -79,19 +38,6 @@ define float @fnearbyint(float %a) {
; CHECK-ZFA-f32: # %bb.0:
; CHECK-ZFA-f32-NEXT: fround.s fa0, fa0
; CHECK-ZFA-f32-NEXT: ret
-;
-; CHECK-ZFA-libcall-LABEL: fnearbyint:
-; CHECK-ZFA-libcall: # %bb.0:
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
-; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
-; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
-; CHECK-ZFA-libcall-NEXT: call nearbyintf
-; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
-; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
-; CHECK-ZFA-libcall-NEXT: ret
%b = call float @llvm.nearbyint.f32(float %a)
ret float %b
}
@@ -101,19 +47,6 @@ define float @fround(float %a) {
; CHECK-ZFA-f32: # %bb.0:
; CHECK-ZFA-f32-NEXT: fround.s fa0, fa0, rmm
; CHECK-ZFA-f32-NEXT: ret
-;
-; CHECK-ZFA-libcall-LABEL: fround:
-; CHECK-ZFA-libcall: # %bb.0:
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
-; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
-; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
-; CHECK-ZFA-libcall-NEXT: call roundf
-; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
-; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
-; CHECK-ZFA-libcall-NEXT: ret
%b = call float @llvm.round.f32(float %a)
ret float %b
}
@@ -124,38 +57,24 @@ define float @froundeven(float %a) {
; CHECK-ZFA-f32: # %bb.0:
; CHECK-ZFA-f32-NEXT: fround.s fa0, fa0, rne
; CHECK-ZFA-f32-NEXT: ret
-;
-; CHECK-ZFA-libcall-LABEL: froundeven:
-; CHECK-ZFA-libcall: # %bb.0:
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, -16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 16
-; CHECK-ZFA-libcall-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
-; CHECK-ZFA-libcall-NEXT: .cfi_offset ra, -4
-; CHECK-ZFA-libcall-NEXT: call roundevenf
-; CHECK-ZFA-libcall-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
-; CHECK-ZFA-libcall-NEXT: .cfi_restore ra
-; CHECK-ZFA-libcall-NEXT: addi sp, sp, 16
-; CHECK-ZFA-libcall-NEXT: .cfi_def_cfa_offset 0
-; CHECK-ZFA-libcall-NEXT: ret
%b = call float @llvm.roundeven.f32(float %a)
ret float %b
}
-; TODO fix these tests for libcall
-;;define float @fmaximum(float %a, float %b) {
-;; CHECK-ZFA-f32-LABEL: fmaximum:
-;; CHECK-ZFA-f32: # %bb.0:
-;; CHECK-ZFA-f32-NEXT: fmaxm.s fa0, fa0, fa1
-;; CHECK-ZFA-f32-NEXT: ret
-; %c = call float @llvm.maximum.f32(float %a, float %b)
-; ret float %c
-;}
-;
-;define float @fminimum(float %a, float %b) {
-;; CHECK-ZFA-f32-LABEL: fminimum:
-;; CHECK-ZFA-f32: # %bb.0:
-;; CHECK-ZFA-f32-NEXT: fminm.s fa0, fa0, fa1
-;; CHECK-ZFA-f32-NEXT: ret
-; %c = call float @llvm.minimum.f32(float %a, float %b)
-; ret float %c
-;}
+define float @fmaximum(float %a, float %b) {
+; CHECK-ZFA-f32-LABEL: fmaximum:
+; CHECK-ZFA-f32: # %bb.0:
+; CHECK-ZFA-f32-NEXT: fmaxm.s fa0, fa0, fa1
+; CHECK-ZFA-f32-NEXT: ret
+ %c = call float @llvm.maximum.f32(float %a, float %b)
+ ret float %c
+}
+
+define float @fminimum(float %a, float %b) {
+; CHECK-ZFA-f32-LABEL: fminimum:
+; CHECK-ZFA-f32: # %bb.0:
+; CHECK-ZFA-f32-NEXT: fminm.s fa0, fa0, fa1
+; CHECK-ZFA-f32-NEXT: ret
+ %c = call float @llvm.minimum.f32(float %a, float %b)
+ ret float %c
+}
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/half-zfa.ll b/llvm/test/CodeGen/RISCV/GlobalISel/half-zfa.ll
index 5d907063354c41..7d31cf536d3d20 100644
--- a/llvm/test/CodeGen/RISCV/GlobalISel/half-zfa.ll
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/half-zfa.ll
@@ -8,71 +8,71 @@
define half @fceil(half %a) {
; CHECK-ZFA-f16-LABEL: fceil:
-; CHECK-ZFA-f16: # %bb.0:
-; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rup
-; CHECK-ZFA-f16-NEXT: ret
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rup
+; CHECK-ZFA-f16-NEXT: ret
%b = call half @llvm.ceil.f16(half %a)
ret half %b
}
define half @ffloor(half %a) {
; CHECK-ZFA-f16-LABEL: ffloor:
-; CHECK-ZFA-f16: # %bb.0:
-; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rdn
-; CHECK-ZFA-f16-NEXT: ret
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rdn
+; CHECK-ZFA-f16-NEXT: ret
%b = call half @llvm.floor.f16(half %a)
ret half %b
}
define half @frint(half %a) {
; CHECK-ZFA-f16-LABEL: frint:
-; CHECK-ZFA-f16: # %bb.0:
-; CHECK-ZFA-f16-NEXT: froundnx.h fa0, fa0
-; CHECK-ZFA-f16-NEXT: ret
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: froundnx.h fa0, fa0
+; CHECK-ZFA-f16-NEXT: ret
%b = call half @llvm.rint.f16(half %a)
ret half %b
}
define half @fnearbyint(half %a) {
; CHECK-ZFA-f16-LABEL: fnearbyint:
-; CHECK-ZFA-f16: # %bb.0:
-; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0
-; CHECK-ZFA-f16-NEXT: ret
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0
+; CHECK-ZFA-f16-NEXT: ret
%b = call half @llvm.nearbyint.f16(half %a)
ret half %b
}
define half @fround(half %a) {
; CHECK-ZFA-f16-LABEL: fround:
-; CHECK-ZFA-f16: # %bb.0:
-; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rmm
-; CHECK-ZFA-f16-NEXT: ret
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rmm
+; CHECK-ZFA-f16-NEXT: ret
%b = call half @llvm.round.f16(half %a)
ret half %b
}
define half @froundeven(half %a) {
; CHECK-ZFA-f16-LABEL: froundeven:
-; CHECK-ZFA-f16: # %bb.0:
-; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rne
-; CHECK-ZFA-f16-NEXT: ret
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fround.h fa0, fa0, rne
+; CHECK-ZFA-f16-NEXT: ret
%b = call half @llvm.roundeven.f16(half %a)
ret half %b
}
define half @fmaximum(half %a, half %b) {
; CHECK-ZFA-f16-LABEL: fmaximum:
-; CHECK-ZFA-f16: # %bb.0:
-; CHECK-ZFA-f16-NEXT: fmaxm.h fa0, fa0, fa1
-; CHECK-ZFA-f16-NEXT: ret
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fmaxm.h fa0, fa0, fa1
+; CHECK-ZFA-f16-NEXT: ret
%c = call half @llvm.maximum.f16(half %a, half %b)
ret half %c
}
define half @fminimum(half %a, half %b) {
; CHECK-ZFA-f16-LABEL: fminimum:
-; CHECK-ZFA-f16: # %bb.0:
-; CHECK-ZFA-f16-NEXT: fminm.h fa0, fa0, fa1
-; CHECK-ZFA-f16-NEXT: ret
+; CHECK-ZFA-f16: # %bb.0:
+; CHECK-ZFA-f16-NEXT: fminm.h fa0, fa0, fa1
+; CHECK-ZFA-f16-NEXT: ret
%c = call half @llvm.minimum.f16(half %a, half %b)
ret half %c
}
More information about the llvm-commits
mailing list