Example #1
0
// Adds the edge F -> T with weight Weight.
APInt IneqGraph::findShortestPath(Value *F, Value *T) {
  DEBUG(dbgs() << "IneqGraph: findShortestPath: " << *F << " ==> " << *T << "\n");
  if (isa<ConstantInt>(F) || isa<ConstantInt>(T)) {
    APInt RangeF = getUpper(F);
    APInt RangeT = getLower(T);
    DEBUG(dbgs() << "Ranges: " << RangeF << " and " << RangeT << "\n");
    if (RangeF.isMaxSignedValue() || RangeF.isMinSignedValue() ||
        RangeT.isMaxSignedValue() || RangeT.isMinSignedValue())
      return APInt::getSignedMaxValue(64);
    return RangeF.sextOrSelf(64) - RangeT.sextOrSelf(64);
  }
  GraphNode *FN = getOrCreateNode(F);
  GraphNode *TN = getOrCreateNode(T);
  return FN->findShortestPath(TN);
}