public final int getMinimumRegisterRequirement(BitSet compatRegs) {
    boolean hasResult = hasResult();
    int regSz = registers.size();
    int resultRequirement = 0;
    int sourceRequirement = 0;

    if (hasResult && !compatRegs.get(0)) {
      resultRequirement = registers.get(0).getCategory();
    }

    for (int i = hasResult ? 1 : 0; i < regSz; i++) {
      if (!compatRegs.get(i)) {
        sourceRequirement += registers.get(i).getCategory();
      }
    }

    return Math.max(sourceRequirement, resultRequirement);
  }
Gets the minimum distinct registers required for this instruction. Uses the given BitSet to
determine which registers require replacement, and ignores registers that are already
compatible. This assumes that the result (if any) can share registers with the sources (if
any), that each source register is unique, and that (to be explicit here) category-2 values
take up two consecutive registers.

@param compatRegs {@code non-null;} set of compatible registers
@return {@code >= 0;} the minimum distinct register requirement
android/android_framework/dex-maker/src/main/java/com/android/dx/dex/code/DalvInsn.java