[llvm] 5d47e7d - [RISCV] Convert whole register copies as the source defined explicitly.
Hsiangkai Wang via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 26 22:00:07 PST 2021
Author: Hsiangkai Wang
Date: 2021-12-27T13:59:49+08:00
New Revision: 5d47e7d768951a7616ee19f12ef69cd50e02d230
URL: https://github.com/llvm/llvm-project/commit/5d47e7d768951a7616ee19f12ef69cd50e02d230
DIFF: https://github.com/llvm/llvm-project/commit/5d47e7d768951a7616ee19f12ef69cd50e02d230.diff
LOG: [RISCV] Convert whole register copies as the source defined explicitly.
The implicit defines may come from a partial define in an instruction.
It does not mean the defining instruction and the COPY instruction have
the same vl and vtype. When the source comes from the implicit defines,
do not convert the whole register copies to vmv.v.v.
Differential Revision: https://reviews.llvm.org/D115866
Added:
Modified:
llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
llvm/test/CodeGen/RISCV/rvv/vmv-copy.mir
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index 2e2e00886d57a..dee1ce635c735 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -201,8 +201,9 @@ static bool isConvertibleToVMV_V_V(const RISCVSubtarget &STI,
if (MBBI->modifiesRegister(RISCV::VL))
return false;
- // Go through all defined operands, including implicit defines.
- for (const MachineOperand &MO : MBBI->operands()) {
+ // Only converting whole register copies to vmv.v.v when the defining
+ // value appears in the explicit operands.
+ for (const MachineOperand &MO : MBBI->explicit_operands()) {
if (!MO.isReg() || !MO.isDef())
continue;
if (!FoundDef && TRI->isSubRegisterEq(MO.getReg(), SrcReg)) {
diff --git a/llvm/test/CodeGen/RISCV/rvv/vmv-copy.mir b/llvm/test/CodeGen/RISCV/rvv/vmv-copy.mir
index 19eeea2aa4720..72460189b0854 100644
--- a/llvm/test/CodeGen/RISCV/rvv/vmv-copy.mir
+++ b/llvm/test/CodeGen/RISCV/rvv/vmv-copy.mir
@@ -313,14 +313,14 @@ body: |
; CHECK-NEXT: $v8_v9_v10_v11_v12_v13_v14_v15 = PseudoVLSEG8E32_V_M1 killed $x12, $noreg, 5, implicit $vl, implicit $vtype
; CHECK-NEXT: $x0 = PseudoVSETIVLI 10, 80, implicit-def $vl, implicit-def $vtype
; CHECK-NEXT: $v15 = PseudoVLE32_V_M1 killed $x16, $noreg, 5, implicit $vl, implicit $vtype, implicit killed $v8_v9_v10_v11_v12_v13_v14_v15, implicit-def $v8_v9_v10_v11_v12_v13_v14_v15
- ; CHECK-NEXT: $v24 = PseudoVMV_V_V_M1 killed $v8, $noreg, 5, implicit $vl, implicit $vtype
- ; CHECK-NEXT: $v25 = PseudoVMV_V_V_M1 killed $v9, $noreg, 5, implicit $vl, implicit $vtype
- ; CHECK-NEXT: $v26 = PseudoVMV_V_V_M1 killed $v10, $noreg, 5, implicit $vl, implicit $vtype
- ; CHECK-NEXT: $v27 = PseudoVMV_V_V_M1 killed $v11, $noreg, 5, implicit $vl, implicit $vtype
- ; CHECK-NEXT: $v28 = PseudoVMV_V_V_M1 killed $v12, $noreg, 5, implicit $vl, implicit $vtype
- ; CHECK-NEXT: $v29 = PseudoVMV_V_V_M1 killed $v13, $noreg, 5, implicit $vl, implicit $vtype
- ; CHECK-NEXT: $v30 = PseudoVMV_V_V_M1 killed $v14, $noreg, 5, implicit $vl, implicit $vtype
- ; CHECK-NEXT: $v31 = PseudoVMV_V_V_M1 killed $v15, $noreg, 5, implicit $vl, implicit $vtype
+ ; CHECK-NEXT: $v24 = PseudoVMV1R_V killed $v8
+ ; CHECK-NEXT: $v25 = PseudoVMV1R_V killed $v9
+ ; CHECK-NEXT: $v26 = PseudoVMV1R_V killed $v10
+ ; CHECK-NEXT: $v27 = PseudoVMV1R_V killed $v11
+ ; CHECK-NEXT: $v28 = PseudoVMV1R_V killed $v12
+ ; CHECK-NEXT: $v29 = PseudoVMV1R_V killed $v13
+ ; CHECK-NEXT: $v30 = PseudoVMV1R_V killed $v14
+ ; CHECK-NEXT: $v31 = PseudoVMV1R_V killed $v15
$x0 = PseudoVSETVLI $x14, 80, implicit-def $vl, implicit-def $vtype
$v8_v9_v10_v11_v12_v13_v14_v15 = PseudoVLSEG8E32_V_M1 killed $x12, $noreg, 5, implicit $vl, implicit $vtype
$x0 = PseudoVSETIVLI 10, 80, implicit-def $vl, implicit-def $vtype
More information about the llvm-commits
mailing list