Skip to content

Commit 274f833

Browse files
authored
[RISCV] Don't attempt PRE if available info is SEW/LMUL ratio only (#77063)
1 parent 5dfcb3e commit 274f833

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,11 @@ void RISCVInsertVSETVLI::doPRE(MachineBasicBlock &MBB) {
13811381
if (!UnavailablePred || !AvailableInfo.isValid())
13821382
return;
13831383

1384+
// If we don't know the exact VTYPE, we can't copy the vsetvli to the exit of
1385+
// the unavailable pred.
1386+
if (AvailableInfo.hasSEWLMULRatioOnly())
1387+
return;
1388+
13841389
// Critical edge - TODO: consider splitting?
13851390
if (UnavailablePred->succ_size() != 1)
13861391
return;

llvm/test/CodeGen/RISCV/rvv/vsetvli-insert.mir

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
ret void
7373
}
7474

75+
define void @pre_same_sewlmul_ratio() {
76+
ret void
77+
}
78+
7579
declare <vscale x 1 x i64> @llvm.riscv.vadd.nxv1i64.nxv1i64.i64(<vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, i64) #1
7680

7781
declare <vscale x 1 x i64> @llvm.riscv.vle.nxv1i64.i64(<vscale x 1 x i64>, <vscale x 1 x i64>* nocapture, i64) #4
@@ -446,3 +450,56 @@ body: |
446450
%4:vr = PseudoVMV_V_I_MF4 undef %4, 0, 4, 3, 0
447451
PseudoRET
448452
...
453+
---
454+
# make sure we don't try to perform PRE when one of the blocks is sew/lmul ratio
455+
# only
456+
name: pre_same_sewlmul_ratio
457+
tracksRegLiveness: true
458+
body: |
459+
; CHECK-LABEL: name: pre_same_sewlmul_ratio
460+
; CHECK: bb.0:
461+
; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
462+
; CHECK-NEXT: liveins: $x10
463+
; CHECK-NEXT: {{ $}}
464+
; CHECK-NEXT: %cond:gpr = COPY $x10
465+
; CHECK-NEXT: dead $x0 = PseudoVSETIVLI 2, 215 /* e32, mf2, ta, ma */, implicit-def $vl, implicit-def $vtype
466+
; CHECK-NEXT: [[PseudoVMV_V_I_MF2_:%[0-9]+]]:vr = PseudoVMV_V_I_MF2 $noreg, 1, 2, 5 /* e32 */, 0 /* tu, mu */, implicit $vl, implicit $vtype
467+
; CHECK-NEXT: BEQ %cond, $x0, %bb.2
468+
; CHECK-NEXT: {{ $}}
469+
; CHECK-NEXT: bb.1:
470+
; CHECK-NEXT: successors: %bb.2(0x80000000)
471+
; CHECK-NEXT: {{ $}}
472+
; CHECK-NEXT: dead $x0 = PseudoVSETVLIX0 killed $x0, 216 /* e64, m1, ta, ma */, implicit-def $vl, implicit-def $vtype, implicit $vl
473+
; CHECK-NEXT: [[PseudoVMV_V_I_M1_:%[0-9]+]]:vr = PseudoVMV_V_I_M1 $noreg, 1, 2, 6 /* e64 */, 0 /* tu, mu */, implicit $vl, implicit $vtype
474+
; CHECK-NEXT: {{ $}}
475+
; CHECK-NEXT: bb.2:
476+
; CHECK-NEXT: successors: %bb.4(0x40000000), %bb.3(0x40000000)
477+
; CHECK-NEXT: {{ $}}
478+
; CHECK-NEXT: BEQ %cond, $x0, %bb.4
479+
; CHECK-NEXT: {{ $}}
480+
; CHECK-NEXT: bb.3:
481+
; CHECK-NEXT: successors: %bb.4(0x80000000)
482+
; CHECK-NEXT: {{ $}}
483+
; CHECK-NEXT: PseudoCALL $noreg, csr_ilp32_lp64
484+
; CHECK-NEXT: {{ $}}
485+
; CHECK-NEXT: bb.4:
486+
; CHECK-NEXT: $x0 = PseudoVSETIVLI 2, 215 /* e32, mf2, ta, ma */, implicit-def $vl, implicit-def $vtype
487+
; CHECK-NEXT: [[PseudoVMV_X_S_MF2_:%[0-9]+]]:gpr = PseudoVMV_X_S_MF2 $noreg, 5 /* e32 */, implicit $vtype
488+
; CHECK-NEXT: [[PseudoVMV_V_I_MF2_1:%[0-9]+]]:vr = PseudoVMV_V_I_MF2 $noreg, 1, 2, 5 /* e32 */, 0 /* tu, mu */, implicit $vl, implicit $vtype
489+
; CHECK-NEXT: PseudoRET
490+
bb.0:
491+
liveins: $x10
492+
%cond:gpr = COPY $x10
493+
%1:vr = PseudoVMV_V_I_MF2 $noreg, 1, 2, 5, 0
494+
BEQ %cond, $x0, %bb.2
495+
bb.1:
496+
%2:vr = PseudoVMV_V_I_M1 $noreg, 1, 2, 6, 0
497+
bb.2: ; the exit info here should have sew/lmul ratio only
498+
BEQ %cond, $x0, %bb.4
499+
bb.3:
500+
PseudoCALL $noreg, csr_ilp32_lp64
501+
bb.4: ; this block will have PRE attempted on it
502+
%4:gpr = PseudoVMV_X_S_MF2 $noreg, 5
503+
%5:vr = PseudoVMV_V_I_MF2 $noreg, 1, 2, 5, 0
504+
PseudoRET
505+
...

0 commit comments

Comments
 (0)