[llvm] 21a0176 - [RISCV] Rematerialize vfmv.v.f (#108007)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 10 18:38:32 PDT 2024
Author: Luke Lau
Date: 2024-09-11T09:38:29+08:00
New Revision: 21a0176c584c47218f20322641af8a855b8ce5e2
URL: https://github.com/llvm/llvm-project/commit/21a0176c584c47218f20322641af8a855b8ce5e2
DIFF: https://github.com/llvm/llvm-project/commit/21a0176c584c47218f20322641af8a855b8ce5e2.diff
LOG: [RISCV] Rematerialize vfmv.v.f (#108007)
This is the same principle as vmv.v.x in #107993, but for floats.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
llvm/test/CodeGen/RISCV/rvv/remat.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index 2bb9df4ead0e9c..a805c68e7795c6 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -170,6 +170,7 @@ bool RISCVInstrInfo::isReallyTriviallyReMaterializable(
const MachineInstr &MI) const {
switch (RISCV::getRVVMCOpcode(MI.getOpcode())) {
case RISCV::VMV_V_X:
+ case RISCV::VFMV_V_F:
case RISCV::VMV_V_I:
case RISCV::VID_V:
if (MI.getOperand(1).isUndef() &&
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
index c6cecb7d07182f..2eceef5066f770 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
@@ -6558,6 +6558,7 @@ defm PseudoVFMERGE : VPseudoVMRG_FM;
//===----------------------------------------------------------------------===//
// 13.16. Vector Floating-Point Move Instruction
//===----------------------------------------------------------------------===//
+let isReMaterializable = 1 in
defm PseudoVFMV_V : VPseudoVMV_F;
//===----------------------------------------------------------------------===//
diff --git a/llvm/test/CodeGen/RISCV/rvv/remat.ll b/llvm/test/CodeGen/RISCV/rvv/remat.ll
index 514612cd0525d8..343b086898c143 100644
--- a/llvm/test/CodeGen/RISCV/rvv/remat.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/remat.ll
@@ -312,3 +312,68 @@ define void @vmv.v.x_live(ptr %p, i64 %x) {
store volatile i64 %x, ptr %p
ret void
}
+
+define void @vfmv.v.f(ptr %p, double %x) {
+; POSTRA-LABEL: vfmv.v.f:
+; POSTRA: # %bb.0:
+; POSTRA-NEXT: vsetvli a1, zero, e64, m8, ta, ma
+; POSTRA-NEXT: vfmv.v.f v8, fa0
+; POSTRA-NEXT: vs8r.v v8, (a0)
+; POSTRA-NEXT: vl8re64.v v16, (a0)
+; POSTRA-NEXT: vl8re64.v v24, (a0)
+; POSTRA-NEXT: vl8re64.v v0, (a0)
+; POSTRA-NEXT: vl8re64.v v8, (a0)
+; POSTRA-NEXT: vs8r.v v8, (a0)
+; POSTRA-NEXT: vs8r.v v0, (a0)
+; POSTRA-NEXT: vs8r.v v24, (a0)
+; POSTRA-NEXT: vs8r.v v16, (a0)
+; POSTRA-NEXT: vfmv.v.f v8, fa0
+; POSTRA-NEXT: vs8r.v v8, (a0)
+; POSTRA-NEXT: fsd fa0, 0(a0)
+; POSTRA-NEXT: ret
+;
+; PRERA-LABEL: vfmv.v.f:
+; PRERA: # %bb.0:
+; PRERA-NEXT: addi sp, sp, -16
+; PRERA-NEXT: .cfi_def_cfa_offset 16
+; PRERA-NEXT: csrr a1, vlenb
+; PRERA-NEXT: slli a1, a1, 3
+; PRERA-NEXT: sub sp, sp, a1
+; PRERA-NEXT: .cfi_escape 0x0f, 0x0d, 0x72, 0x00, 0x11, 0x10, 0x22, 0x11, 0x08, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # sp + 16 + 8 * vlenb
+; PRERA-NEXT: vsetvli a1, zero, e64, m8, ta, ma
+; PRERA-NEXT: vfmv.v.f v8, fa0
+; PRERA-NEXT: vs8r.v v8, (a0)
+; PRERA-NEXT: vl8re64.v v16, (a0)
+; PRERA-NEXT: addi a1, sp, 16
+; PRERA-NEXT: vs8r.v v16, (a1) # Unknown-size Folded Spill
+; PRERA-NEXT: vl8re64.v v24, (a0)
+; PRERA-NEXT: vl8re64.v v0, (a0)
+; PRERA-NEXT: vl8re64.v v16, (a0)
+; PRERA-NEXT: vs8r.v v16, (a0)
+; PRERA-NEXT: vs8r.v v0, (a0)
+; PRERA-NEXT: vs8r.v v24, (a0)
+; PRERA-NEXT: vl8r.v v16, (a1) # Unknown-size Folded Reload
+; PRERA-NEXT: vs8r.v v16, (a0)
+; PRERA-NEXT: vs8r.v v8, (a0)
+; PRERA-NEXT: fsd fa0, 0(a0)
+; PRERA-NEXT: csrr a0, vlenb
+; PRERA-NEXT: slli a0, a0, 3
+; PRERA-NEXT: add sp, sp, a0
+; PRERA-NEXT: addi sp, sp, 16
+; PRERA-NEXT: ret
+ %vfmv.v.f = call <vscale x 8 x double> @llvm.riscv.vfmv.v.f.nxv8f64(<vscale x 8 x double> poison, double %x, i64 -1)
+ store volatile <vscale x 8 x double> %vfmv.v.f, ptr %p
+
+ %a = load volatile <vscale x 8 x double>, ptr %p
+ %b = load volatile <vscale x 8 x double>, ptr %p
+ %c = load volatile <vscale x 8 x double>, ptr %p
+ %d = load volatile <vscale x 8 x double>, ptr %p
+ store volatile <vscale x 8 x double> %d, ptr %p
+ store volatile <vscale x 8 x double> %c, ptr %p
+ store volatile <vscale x 8 x double> %b, ptr %p
+ store volatile <vscale x 8 x double> %a, ptr %p
+
+ store volatile <vscale x 8 x double> %vfmv.v.f, ptr %p
+ store volatile double %x, ptr %p
+ ret void
+}
More information about the llvm-commits
mailing list