[llvm] [RISCV][VLOPT] Add vmv.x.s and vfmv.f.s to isVectorOpUsedAsScalarOp (PR #121588)

Michael Maitland via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 3 09:59:56 PST 2025


https://github.com/michaelmaitland created https://github.com/llvm/llvm-project/pull/121588

None

>From eb7cc5e60eab6f832aa9087eebe315800cca703b Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Fri, 3 Jan 2025 09:57:03 -0800
Subject: [PATCH 1/2] [RISCV][VLOPT] Precommit test case

---
 llvm/test/CodeGen/RISCV/rvv/vl-opt.mir | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/llvm/test/CodeGen/RISCV/rvv/vl-opt.mir b/llvm/test/CodeGen/RISCV/rvv/vl-opt.mir
index 3f966b036589fd..2df317c4e975ad 100644
--- a/llvm/test/CodeGen/RISCV/rvv/vl-opt.mir
+++ b/llvm/test/CodeGen/RISCV/rvv/vl-opt.mir
@@ -110,4 +110,17 @@ body: |
     %y:vr = PseudoVADD_VV_M1 $noreg, %x, $noreg, 1, 3 /* e8 */, 0
     %z:vr = PseudoVADD_VV_M1 $noreg, %x, $noreg, -1, 3 /* e8 */, 0
 ...
+---
+name: vmv_is_used_as_scalar_op
+body: |
+  bb.0:
+    liveins: $x1
+    ; CHECK-LABEL: name: vmv_is_used_as_scalar_op
+    ; CHECK: liveins: $x1
+    ; CHECK-NEXT: {{  $}}
+    ; CHECK-NEXT: %x:vr = PseudoVADD_VV_MF4 $noreg, $noreg, $noreg, 1, 3 /* e8 */, 0 /* tu, mu */
+    ; CHECK-NEXT: %y:gpr = PseudoVMV_X_S %x, 3 /* e8 */
+    %x:vr = PseudoVADD_VV_MF4 $noreg, $noreg, $noreg, -1, 3 /* e8 */, 0 /* tu, mu */
+    %y:gpr = PseudoVMV_X_S %x, 3 /* e8 */
+...
 

>From 47c450f3e66a75ba741dd4036d1e9ca71544caef Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Fri, 3 Jan 2025 09:57:52 -0800
Subject: [PATCH 2/2] [RISCV][VLOPT] Add vmv.x.s and vfmv.f.s to
 isVectorOpUsedAsScalarOp

---
 llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp b/llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp
index 85ea5a23e8f293..14b0c9d641d2d7 100644
--- a/llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp
+++ b/llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp
@@ -840,6 +840,9 @@ static bool isVectorOpUsedAsScalarOp(MachineOperand &MO) {
   case RISCV::VFWREDOSUM_VS:
   case RISCV::VFWREDUSUM_VS:
     return MO.getOperandNo() == 3;
+  case RISCV::VMV_X_S:
+  case RISCV::VFMV_F_S:
+    return MO.getOperandNo() == 1;
   default:
     return false;
   }



More information about the llvm-commits mailing list