Slot index numbering why use InstrDist = 4 * Slot_Count as the default dist?

when i use the liveInterval anlaysis pass.
I have checked the follwing code:

    enum {
      /// The default distance between instructions as returned by distance().
      /// This may vary as instructions are inserted and removed.
      InstrDist = 4 * Slot_Count
    };

why this design?

I don’t know, but I think this should be increased

There was a previous discussion about this here: Odd behavior in SlotIndex::getInstrDistance()

IIRC, slot indexes are assigned in increments of 4. This is so that inserting an instruction doesn’t require immediate re-indexing.

+1

@zhou3968322 Why do you care about the distance?
This should be an implementation detail.

Why? Do you see a lot of time spent in renumbering? Intuitively I wouldn’t expect it to be that common for regalloc and other passes to insert more than 3 new instructions between two instructions from earlier passes…

This happens all the time when you have 32 element register tuples

Shouldn’t be a big deal to increase it. Though we probably have to be a bit careful as SlotIndexes are only unsigned (aka 32bits) and I see no code even checking for overflows right now…

I’m just curious about this design.
1/4 might be a number that is sparse enough but also keeps the slot relatively dense.