Skip to content

Commit 69f64de

Browse files
committed
[RISCV] Use DemandedFields instead of checking for vmv.s.x/vmv.x.s. NFC
The property we're explicitly looking for is whether or not MI only cares about VL zeroness and not VL itself, so we can just use DemandedFields for this. This should simplify an upcoming change in #72352
1 parent 95d584c commit 69f64de

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,17 +1043,16 @@ void RISCVInsertVSETVLI::transferBefore(VSETVLIInfo &Info,
10431043
Info.setVLMul(*NewVLMul);
10441044
}
10451045

1046-
// For vmv.s.x and vfmv.s.f, there are only two behaviors, VL = 0 and
1047-
// VL > 0. We can discard the user requested AVL and just use the last
1048-
// one if we can prove it equally zero. This removes a vsetvli entirely
1049-
// if the types match or allows use of cheaper avl preserving variant
1050-
// if VLMAX doesn't change. If VLMAX might change, we couldn't use
1051-
// the 'vsetvli x0, x0, vtype" variant, so we avoid the transform to
1052-
// prevent extending live range of an avl register operand.
1046+
// If we only demand VL zeroness (i.e. vmv.s.x and vmv.x.s), then there are
1047+
// only two behaviors, VL = 0 and VL > 0. We can discard the user requested
1048+
// AVL and just use the last one if we can prove it equally zero. This
1049+
// removes a vsetvli entirely if the types match or allows use of cheaper avl
1050+
// preserving variant if VLMAX doesn't change. If VLMAX might change, we
1051+
// couldn't use the 'vsetvli x0, x0, vtype" variant, so we avoid the transform
1052+
// to prevent extending live range of an avl register operand.
10531053
// TODO: We can probably relax this for immediates.
1054-
if (isScalarInsertInstr(MI) && PrevInfo.isValid() &&
1055-
PrevInfo.hasEquallyZeroAVL(Info, *MRI) &&
1056-
Info.hasSameVLMAX(PrevInfo)) {
1054+
if (Demanded.VLZeroness && !Demanded.VLAny && PrevInfo.isValid() &&
1055+
PrevInfo.hasEquallyZeroAVL(Info, *MRI) && Info.hasSameVLMAX(PrevInfo)) {
10571056
if (PrevInfo.hasAVLImm())
10581057
Info.setAVLImm(PrevInfo.getAVLImm());
10591058
else

0 commit comments

Comments
 (0)