[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
Sun Jan 5 08:18:59 PST 2025


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

>From 0a26f9c1bd68a0bb7c993436218bdc04b5c4b6e8 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/3] [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..5815108428b1f9 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 8f29da7ccb0f69a97966b3484712cea423232f1d 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/3] [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;
   }

>From 620ff27a5d620ccd79eab363d9a0ba55eea2c4a9 Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Sun, 5 Jan 2025 08:18:41 -0800
Subject: [PATCH 3/3] fixup! remove test

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

diff --git a/llvm/test/CodeGen/RISCV/rvv/vl-opt.mir b/llvm/test/CodeGen/RISCV/rvv/vl-opt.mir
index 5815108428b1f9..3f966b036589fd 100644
--- a/llvm/test/CodeGen/RISCV/rvv/vl-opt.mir
+++ b/llvm/test/CodeGen/RISCV/rvv/vl-opt.mir
@@ -110,17 +110,4 @@ 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 */
-...
 



More information about the llvm-commits mailing list