Skip to content

Commit 5d47e7d

Browse files
committed
[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
1 parent 6441536 commit 5d47e7d

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

Diff for: llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,9 @@ static bool isConvertibleToVMV_V_V(const RISCVSubtarget &STI,
201201
if (MBBI->modifiesRegister(RISCV::VL))
202202
return false;
203203

204-
// Go through all defined operands, including implicit defines.
205-
for (const MachineOperand &MO : MBBI->operands()) {
204+
// Only converting whole register copies to vmv.v.v when the defining
205+
// value appears in the explicit operands.
206+
for (const MachineOperand &MO : MBBI->explicit_operands()) {
206207
if (!MO.isReg() || !MO.isDef())
207208
continue;
208209
if (!FoundDef && TRI->isSubRegisterEq(MO.getReg(), SrcReg)) {

Diff for: llvm/test/CodeGen/RISCV/rvv/vmv-copy.mir

+8-8
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,14 @@ body: |
313313
; CHECK-NEXT: $v8_v9_v10_v11_v12_v13_v14_v15 = PseudoVLSEG8E32_V_M1 killed $x12, $noreg, 5, implicit $vl, implicit $vtype
314314
; CHECK-NEXT: $x0 = PseudoVSETIVLI 10, 80, implicit-def $vl, implicit-def $vtype
315315
; 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
316-
; CHECK-NEXT: $v24 = PseudoVMV_V_V_M1 killed $v8, $noreg, 5, implicit $vl, implicit $vtype
317-
; CHECK-NEXT: $v25 = PseudoVMV_V_V_M1 killed $v9, $noreg, 5, implicit $vl, implicit $vtype
318-
; CHECK-NEXT: $v26 = PseudoVMV_V_V_M1 killed $v10, $noreg, 5, implicit $vl, implicit $vtype
319-
; CHECK-NEXT: $v27 = PseudoVMV_V_V_M1 killed $v11, $noreg, 5, implicit $vl, implicit $vtype
320-
; CHECK-NEXT: $v28 = PseudoVMV_V_V_M1 killed $v12, $noreg, 5, implicit $vl, implicit $vtype
321-
; CHECK-NEXT: $v29 = PseudoVMV_V_V_M1 killed $v13, $noreg, 5, implicit $vl, implicit $vtype
322-
; CHECK-NEXT: $v30 = PseudoVMV_V_V_M1 killed $v14, $noreg, 5, implicit $vl, implicit $vtype
323-
; CHECK-NEXT: $v31 = PseudoVMV_V_V_M1 killed $v15, $noreg, 5, implicit $vl, implicit $vtype
316+
; CHECK-NEXT: $v24 = PseudoVMV1R_V killed $v8
317+
; CHECK-NEXT: $v25 = PseudoVMV1R_V killed $v9
318+
; CHECK-NEXT: $v26 = PseudoVMV1R_V killed $v10
319+
; CHECK-NEXT: $v27 = PseudoVMV1R_V killed $v11
320+
; CHECK-NEXT: $v28 = PseudoVMV1R_V killed $v12
321+
; CHECK-NEXT: $v29 = PseudoVMV1R_V killed $v13
322+
; CHECK-NEXT: $v30 = PseudoVMV1R_V killed $v14
323+
; CHECK-NEXT: $v31 = PseudoVMV1R_V killed $v15
324324
$x0 = PseudoVSETVLI $x14, 80, implicit-def $vl, implicit-def $vtype
325325
$v8_v9_v10_v11_v12_v13_v14_v15 = PseudoVLSEG8E32_V_M1 killed $x12, $noreg, 5, implicit $vl, implicit $vtype
326326
$x0 = PseudoVSETIVLI 10, 80, implicit-def $vl, implicit-def $vtype

0 commit comments

Comments
 (0)