Skip to content

Commit

Permalink
[RISCV][InsertVSETVLI] Relax tail policy more often for vmv.s.x
Browse files Browse the repository at this point in the history
If a vm.s.x pseudo has an undef passthru operand, then we're free to use
whatever tail policy we want for VL > 1. We previously relaxed the tail
policy for this but only when we could also expand the SEW.
This patch changes it to relax the tail policy even if the SEW can't be
expanded and removes a few more toggles, as well as fully moving the
vmv.s.x logic into getDemanded.
  • Loading branch information
lukel97 committed May 31, 2023
1 parent badf11d commit f3b39ce
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 438 deletions.
15 changes: 1 addition & 14 deletions llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ DemandedFields getDemanded(const MachineInstr &MI,
auto *VRegDef = MRI->getVRegDef(MI.getOperand(1).getReg());
if (VRegDef && VRegDef->isImplicitDef()) {
Res.SEW = DemandedFields::SEWGreaterThanOrEqual;
Res.TailPolicy = false;
}
}

Expand Down Expand Up @@ -889,20 +890,6 @@ bool RISCVInsertVSETVLI::needVSETVLI(const MachineInstr &MI,

DemandedFields Used = getDemanded(MI, MRI);

if (isScalarMoveInstr(MI)) {
// For vmv.s.x and vfmv.s.f, if writing to an implicit_def operand, we don't
// need to preserve any other bits and are thus compatible with any larger,
// etype and can disregard policy bits. Warning: It's tempting to try doing
// this for any tail agnostic operation, but we can't as TA requires
// tail lanes to either be the original value or -1. We are writing
// unknown bits to the lanes here.
auto *VRegDef = MRI->getVRegDef(MI.getOperand(1).getReg());
if (VRegDef && VRegDef->isImplicitDef() &&
CurInfo.getSEW() >= Require.getSEW()) {
Used.TailPolicy = false;
}
}

// A slidedown/slideup with an IMPLICIT_DEF merge op can freely clobber
// elements not copied from the source vector (e.g. masked off, tail, or
// slideup's prefix). Notes:
Expand Down
3 changes: 1 addition & 2 deletions llvm/test/CodeGen/RISCV/rvv/fixed-vectors-mask-buildvec.ll
Original file line number Diff line number Diff line change
Expand Up @@ -745,12 +745,11 @@ define <128 x i1> @buildvec_mask_v128i1() {
; RV32-LMULMAX8: # %bb.0:
; RV32-LMULMAX8-NEXT: lui a0, 748388
; RV32-LMULMAX8-NEXT: addi a0, a0, -1793
; RV32-LMULMAX8-NEXT: vsetivli zero, 4, e32, m1, ta, ma
; RV32-LMULMAX8-NEXT: vsetivli zero, 2, e32, m1, tu, ma
; RV32-LMULMAX8-NEXT: vmv.s.x v8, a0
; RV32-LMULMAX8-NEXT: lui a0, 748384
; RV32-LMULMAX8-NEXT: addi a0, a0, 1776
; RV32-LMULMAX8-NEXT: vmv.s.x v0, a0
; RV32-LMULMAX8-NEXT: vsetivli zero, 2, e32, m1, tu, ma
; RV32-LMULMAX8-NEXT: vslideup.vi v0, v8, 1
; RV32-LMULMAX8-NEXT: lui a0, 551776
; RV32-LMULMAX8-NEXT: addi a0, a0, 1776
Expand Down

0 comments on commit f3b39ce

Please sign in to comment.