- TypeSet InputSet(Other);
- MVT Smallest = TypeVec[0];
- for (unsigned i = 0; i != Other.TypeVec.size(); ++i) {
- MVT OtherVT = Other.TypeVec[i];
- // Don't compare vector and non-vector types.
- if (OtherVT.isVector() != Smallest.isVector())
- continue;
- // The getSizeInBits() check here is only needed for vectors, but is
- // a subset of the scalar check for scalars so no need to qualify.
- if (OtherVT.getScalarSizeInBits() <= Smallest.getScalarSizeInBits() ||
- OtherVT.getSizeInBits() < Smallest.getSizeInBits()) {
- Other.TypeVec.erase(Other.TypeVec.begin()+i--);
- MadeChange = true;
+ {
+ TypeSet InputSet(Other);
+ MVT Smallest = TypeVec[0];
+ auto I = std::remove_if(Other.TypeVec.begin(), Other.TypeVec.end(),
+ [Smallest](MVT OtherVT) {
+ // Don't compare vector and non-vector types.
+ if (OtherVT.isVector() != Smallest.isVector())
+ return false;
+ // The getSizeInBits() check here is only needed for vectors, but is
+ // a subset of the scalar check for scalars so no need to qualify.
+ return OtherVT.getScalarSizeInBits() <= Smallest.getScalarSizeInBits()||
+ OtherVT.getSizeInBits() < Smallest.getSizeInBits();
+ });
+ MadeChange |= I != Other.TypeVec.end(); // If we're about to remove types.
+ Other.TypeVec.erase(I, Other.TypeVec.end());
+
+ if (Other.TypeVec.empty()) {
+ TP.error("Type inference contradiction found, '" + InputSet.getName() +
+ "' has nothing larger than '" + getName() +"'!");
+ return false;