Skip to content

Commit

Permalink
[RISCV] Properly handle partial writes in isConvertibleToVMV_V_V.
Browse files Browse the repository at this point in the history
We were only checking for the previous insructions to write exactly
the register or a super register. We ignored writes to a subregister
and continued searching for the producing instruction. We need to
abort instead.

There's another check inside the if body to abort if the registers
don't match exactly. So we just need to check for overlap so we
enter the if body.

Reviewed By: fakepaper56

Differential Revision: https://reviews.llvm.org/D153490
  • Loading branch information
topperc committed Jun 26, 2023
1 parent 43e57bd commit b105b32
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ static bool isConvertibleToVMV_V_V(const RISCVSubtarget &STI,
for (const MachineOperand &MO : MBBI->explicit_operands()) {
if (!MO.isReg() || !MO.isDef())
continue;
if (!FoundDef && TRI->isSubRegisterEq(MO.getReg(), SrcReg)) {
if (!FoundDef && TRI->regsOverlap(MO.getReg(), SrcReg)) {
// We only permit the source of COPY has the same LMUL as the defined
// operand.
// There are cases we need to keep the whole register copy if the LMUL
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/RISCV/rvv/vmv-copy.mir
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ body: |
; CHECK-NEXT: $v10m2 = PseudoVLE16_V_M2 killed $x11, $noreg, 4 /* e16 */, implicit $vl, implicit $vtype
; CHECK-NEXT: $v10 = VMV1R_V $v8
; CHECK-NEXT: $v11 = VMV1R_V $v9
; CHECK-NEXT: $v12m2 = PseudoVMV_V_V_M2 $v10m2, $noreg, 4 /* e16 */, implicit $vl, implicit $vtype
; CHECK-NEXT: $v12m2 = VMV2R_V $v10m2
$x0 = PseudoVSETVLI $x10, 201, implicit-def $vl, implicit-def $vtype
$v10m2 = PseudoVLE16_V_M2 killed $x11, $noreg, 4, implicit $vl, implicit $vtype
$v10 = COPY $v8
Expand Down

0 comments on commit b105b32

Please sign in to comment.