bool Inst::operator<(const Inst &Other) const { if (this == &Other) return false; if (K < Other.K) return true; if (K > Other.K) return false; if (Width < Other.Width) return true; if (Width > Other.Width) return false; switch (K) { case Const: return Val.ult(Other.Val); case UntypedConst: { llvm::APInt Val1 = Val, Val2 = Other.Val; if (Val1.getBitWidth() < Val2.getBitWidth()) Val1 = Val1.sext(Val2.getBitWidth()); else if (Val1.getBitWidth() > Val2.getBitWidth()) Val2 = Val2.sext(Val1.getBitWidth()); return Val1.slt(Val2); } case Var: return Number < Other.Number; case Phi: if (B->Number < Other.B->Number) return true; if (B->Number > Other.B->Number) return false; default: break; } if (Ops.size() < Other.Ops.size()) return true; if (Ops.size() > Other.Ops.size()) return false; const std::vector<Inst *> &OpsA = orderedOps(); const std::vector<Inst *> &OpsB = Other.orderedOps(); for (unsigned I = 0; I != OpsA.size(); ++I) { if (OpsA[I] == OpsB[I]) continue; return (*OpsA[I] < *OpsB[I]); } llvm_unreachable("Should have found an unequal operand"); }