Skip to content

Commit 7d06bdc

Browse files
authored
[RISCV] Use isCompatible when we need runtime VSETVLIInfo equality. NFC (#94340)
In VSETVLIInfo we define == as lattice equality, e.g. unknown == unknown and invalid == invalid. We need this to check if the information at a block's entry or exit has changed. However I think we may have been conflating it with the notion that the state of VL and VTYPE are the same, which isn't the case for two unknowns, and potentially in an upcoming patch where we don't know the value of an AVL register (see #93796) This patch switches over the use in emitVSETVLIs to use isCompatible with all fields demanded, since we need VL and VTYPE to be known equal at runtime rather than just the VSETVLIInfos to be the same. This should be NFC for now we shouldn't reach here with an unknown state. But it's needed if we're to introduce the notion of an AVLReg with a nullptr ValNo, which will need this non-reflexive equality. Specifically, hasSameAVL should return false for this case, but == should return true.
1 parent 8e95454 commit 7d06bdc

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,13 @@ struct DemandedFields {
249249
VLZeroness = true;
250250
}
251251

252+
static DemandedFields all() {
253+
DemandedFields DF;
254+
DF.demandVTYPE();
255+
DF.demandVL();
256+
return DF;
257+
}
258+
252259
// Make this the result of demanding both the fields in this and B.
253260
void doUnion(const DemandedFields &B) {
254261
VLAny |= B.VLAny;
@@ -713,14 +720,12 @@ class VSETVLIInfo {
713720
const LiveIntervals *LIS) const {
714721
assert(isValid() && Require.isValid() &&
715722
"Can't compare invalid VSETVLIInfos");
716-
assert(!Require.SEWLMULRatioOnly &&
717-
"Expected a valid VTYPE for instruction!");
718723
// Nothing is compatible with Unknown.
719724
if (isUnknown() || Require.isUnknown())
720725
return false;
721726

722727
// If only our VLMAX ratio is valid, then this isn't compatible.
723-
if (SEWLMULRatioOnly)
728+
if (SEWLMULRatioOnly || Require.SEWLMULRatioOnly)
724729
return false;
725730

726731
if (Used.VLAny && !(hasSameAVL(Require) && hasSameVLMAX(Require)))
@@ -1412,7 +1417,7 @@ void RISCVInsertVSETVLI::emitVSETVLIs(MachineBasicBlock &MBB) {
14121417

14131418
uint64_t TSFlags = MI.getDesc().TSFlags;
14141419
if (RISCVII::hasSEWOp(TSFlags)) {
1415-
if (PrevInfo != CurInfo) {
1420+
if (!PrevInfo.isCompatible(DemandedFields::all(), CurInfo, LIS)) {
14161421
// If this is the first implicit state change, and the state change
14171422
// requested can be proven to produce the same register contents, we
14181423
// can skip emitting the actual state change and continue as if we

0 commit comments

Comments
 (0)