private void replaceConstants() {
    for (int reg = 0; reg < regCount; reg++) {
      if (latticeValues[reg] != CONSTANT) {
        continue;
      }
      if (!(latticeConstants[reg] instanceof TypedConstant)) {
        // We can't do much with these
        continue;
      }

      SsaInsn defn = ssaMeth.getDefinitionForRegister(reg);
      TypeBearer typeBearer = defn.getResult().getTypeBearer();

      if (typeBearer.isConstant()) {
        /*
         * The definition was a constant already.
         * The uses should be as well.
         */
        continue;
      }

      // Update the destination RegisterSpec with the constant value
      RegisterSpec dest = defn.getResult();
      RegisterSpec newDest = dest.withType((TypedConstant) latticeConstants[reg]);
      defn.setResult(newDest);

      /*
       * Update the sources RegisterSpec's of all non-move uses.
       * These will be used in later steps.
       */
      for (SsaInsn insn : ssaMeth.getUseListForRegister(reg)) {
        if (insn.isPhiOrMove()) {
          continue;
        }

        NormalSsaInsn nInsn = (NormalSsaInsn) insn;
        RegisterSpecList sources = insn.getSources();

        int index = sources.indexOfRegister(reg);

        RegisterSpec spec = sources.get(index);
        RegisterSpec newSpec = spec.withType((TypedConstant) latticeConstants[reg]);

        nInsn.changeOneSource(index, newSpec);
      }
    }
  }
Replaces TypeBearers in source register specs with constant type bearers if possible. These are
then referenced in later optimization steps.
android/android_framework/dex-maker/src/main/java/com/android/dx/ssa/SCCP.java