Skip to content

Commit 38ad8f6

Browse files
committed
[RISCV] Clear kill flags for FalseReg in foldVMergeToMask
Or we can't pass the MachineVerifier because of using a killed virtual register. This was found when backporting llvm#170070 to 21.x branch.
1 parent 973ccca commit 38ad8f6

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

llvm/lib/Target/RISCV/RISCVVectorPeephole.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,8 @@ bool RISCVVectorPeephole::foldVMergeToMask(MachineInstr &MI) const {
834834
MRI->constrainRegClass(
835835
MO.getReg(), True.getRegClassConstraint(MO.getOperandNo(), TII, TRI));
836836
}
837+
// We should clear the IsKill flag since we have an use now.
838+
MRI->clearKillFlags(FalseReg);
837839
MI.eraseFromParent();
838840

839841
return true;

llvm/test/CodeGen/RISCV/rvv/vmerge-peephole.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ body: |
148148
; CHECK-NEXT: %y:vr = COPY $v9
149149
; CHECK-NEXT: %mask:vmv0 = COPY $v0
150150
; CHECK-NEXT: %add0:vr = PseudoVADD_VV_M1 $noreg, %x, %y, -1, 5 /* e32 */, 3 /* ta, ma */
151-
; CHECK-NEXT: %add1:vrnov0 = COPY killed %add:vrnov0
151+
; CHECK-NEXT: %add1:vrnov0 = COPY %add:vrnov0
152152
; CHECK-NEXT: %merge:vrnov0 = PseudoVOR_VV_M1_MASK %add:vrnov0, %add1, %y, %mask, -1, 5 /* e32 */, 1 /* ta, mu */
153153
; CHECK-NEXT: $v8 = COPY %merge
154154
; CHECK-NEXT: PseudoRET implicit $v8

0 commit comments

Comments
 (0)