Skip to content

Commit 345a352

Browse files
[RISCV][VLOPT] Avoid crash when user produces scalar def (#120255)
I found this crash when trying to enable the VLOptimizer pass. We need this patch before we can enable by default. The old assert was not checking that USE and DEF were vector registers. The correct condition is guarded at the callsite of tryReduceVL.
1 parent fbbbd65 commit 345a352

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -936,12 +936,6 @@ bool RISCVVLOptimizer::checkUsers(const MachineOperand *&CommonVL,
936936
}
937937

938938
// The SEW and LMUL of destination and source registers need to match.
939-
940-
// We know that MI DEF is a vector register, because that was the guard
941-
// to call this function.
942-
assert(isVectorRegClass(UserMI.getOperand(0).getReg(), MRI) &&
943-
"Expected DEF and USE to be vector registers");
944-
945939
OperandInfo ConsumerInfo = getOperandInfo(UserOp, MRI);
946940
OperandInfo ProducerInfo = getOperandInfo(MI.getOperand(0), MRI);
947941
if (ConsumerInfo.isUnknown() || ProducerInfo.isUnknown() ||
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
2+
# RUN: llc %s -o - -mtriple=riscv32 -mattr=+v -run-pass=riscv-vl-optimizer -verify-machineinstrs | FileCheck %s
3+
4+
---
5+
name: vec_instr_with_scalar_def
6+
tracksRegLiveness: true
7+
isSSA: true
8+
body: |
9+
bb.0:
10+
; CHECK-LABEL: name: vec_instr_with_scalar_def
11+
; CHECK: [[PseudoVMNAND_MM_B8_:%[0-9]+]]:vr = PseudoVMNAND_MM_B8 $noreg, $noreg, -1, 0 /* e8 */
12+
; CHECK-NEXT: [[PseudoVCPOP_M_B1_:%[0-9]+]]:gpr = PseudoVCPOP_M_B1 killed [[PseudoVMNAND_MM_B8_]], -1, 0 /* e8 */
13+
%1:vr = PseudoVMNAND_MM_B8 $noreg, $noreg, -1, 0 /* e8 */
14+
%2:gpr = PseudoVCPOP_M_B1 killed %1, -1, 0 /* e8 */
15+
...

0 commit comments

Comments
 (0)