Skip to content

Commit fdf8242

Browse files
committed
fixup! Stop propagation if any of the INSERT_SUBREG is not illegible
1 parent 3bfff33 commit fdf8242

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,9 +1510,10 @@ RISCVVLOptimizer::checkUsers(const MachineInstr &MI) const {
15101510
// or another INSERT_SUBREG, since VL just works differently
15111511
// between segmented operations (per-field) v.s. other RVV ops (on the
15121512
// whole register group).
1513-
if (isTupleInsertInstr(CandidateMI, *MRI) ||
1514-
isSegmentedStoreInstr(CandidateMI))
1515-
Worklist.insert(&UseOp);
1513+
if (!isTupleInsertInstr(CandidateMI, *MRI) &&
1514+
!isSegmentedStoreInstr(CandidateMI))
1515+
return std::nullopt;
1516+
Worklist.insert(&UseOp);
15161517
}
15171518
continue;
15181519
}

llvm/test/CodeGen/RISCV/rvv/vl-opt.mir

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ body: |
667667
bb.0:
668668
liveins: $v8, $v9, $v10
669669
670-
; We should not peekthrough an INSERT_SUBREG if its user is not a segmented store or another INSERT_SUBREG.
670+
; We should not peekthrough an INSERT_SUBREG if any of its users is not a segmented store or another INSERT_SUBREG.
671671
; CHECK-LABEL: name: insert_subreg_bitcast_no_peekthru
672672
; CHECK: liveins: $v8, $v9, $v10
673673
; CHECK-NEXT: {{ $}}
@@ -682,6 +682,9 @@ body: |
682682
; CHECK-NEXT: [[INSERT_SUBREG3:%[0-9]+]]:vrn4m1 = INSERT_SUBREG [[INSERT_SUBREG2]], [[COPY2]], %subreg.sub_vrm1_3
683683
; CHECK-NEXT: [[COPY3:%[0-9]+]]:vrm4 = COPY [[INSERT_SUBREG3]]
684684
; CHECK-NEXT: PseudoVSE32_V_M4 [[COPY3]], $noreg, 1, 5 /* e32 */
685+
; CHECK-NEXT: [[PseudoVADD_VV_M1_1:%[0-9]+]]:vr = PseudoVADD_VV_M1 $noreg, [[PseudoVADD_VV_M1_]], $noreg, 10, 5 /* e32 */, 3 /* ta, ma */
686+
; CHECK-NEXT: $v10 = COPY [[PseudoVADD_VV_M1_1]]
687+
; CHECK-NEXT: PseudoRET implicit $v10
685688
%0:vr = COPY $v8
686689
%1:vr = COPY $v9
687690
%2:vr = PseudoVADD_VV_M1 $noreg, $noreg, $noreg, -1, 5 /* e32 */, 3 /* ta, ma */
@@ -693,3 +696,6 @@ body: |
693696
%9:vrn4m1 = INSERT_SUBREG %8, %3, %subreg.sub_vrm1_3
694697
%10:vrm4 = COPY %9
695698
PseudoVSE32_V_M4 %10:vrm4, $noreg, 1, 5 /* e32 */
699+
%11:vr = PseudoVADD_VV_M1 $noreg, %2, $noreg, 10, 5 /* e32 */, 3 /* ta, ma */
700+
$v10 = COPY %11
701+
PseudoRET implicit $v10

0 commit comments

Comments
 (0)