diff options
author | Craig Topper <craig.topper@gmail.com> | 2015-12-03 05:57:37 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2015-12-03 05:57:37 +0000 |
commit | 1282df50c4f27919cb0b6c49c891baac23df1abf (patch) | |
tree | 16fca2e6a119388b8f9b23370f59448fad4a1e41 | |
parent | 8be749950755072c01024d7e7420d72e7eb6931a (diff) | |
download | bcm5719-llvm-1282df50c4f27919cb0b6c49c891baac23df1abf.tar.gz bcm5719-llvm-1282df50c4f27919cb0b6c49c891baac23df1abf.zip |
[TableGen] Remove an assumption about the order of encodings in the MVT::SimpleValueType enum. Instead of assuming the types are sorted by size, scan the typeset arrays to find the smallest/largest type. NFC
llvm-svn: 254589
-rw-r--r-- | llvm/utils/TableGen/CodeGenDAGPatterns.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp index 3f74a9999c9..3ebe51e0512 100644 --- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp @@ -388,7 +388,13 @@ bool EEVT::TypeSet::EnforceSmallerThan(EEVT::TypeSet &Other, TreePattern &TP) { // the size of the smallest type. { TypeSet InputSet(Other); - MVT Smallest = TypeVec[0]; + MVT Smallest = *std::min_element(TypeVec.begin(), TypeVec.end(), + [](MVT A, MVT B) { + return A.getScalarSizeInBits() < B.getScalarSizeInBits() || + (A.getScalarSizeInBits() == B.getScalarSizeInBits() && + A.getSizeInBits() < B.getSizeInBits()); + }); + auto I = std::remove_if(Other.TypeVec.begin(), Other.TypeVec.end(), [Smallest](MVT OtherVT) { // Don't compare vector and non-vector types. @@ -416,7 +422,12 @@ bool EEVT::TypeSet::EnforceSmallerThan(EEVT::TypeSet &Other, TreePattern &TP) { // the size of the largest type. { TypeSet InputSet(*this); - MVT Largest = Other.TypeVec[Other.TypeVec.size()-1]; + MVT Largest = *std::max_element(Other.TypeVec.begin(), Other.TypeVec.end(), + [](MVT A, MVT B) { + return A.getScalarSizeInBits() < B.getScalarSizeInBits() || + (A.getScalarSizeInBits() == B.getScalarSizeInBits() && + A.getSizeInBits() < B.getSizeInBits()); + }); auto I = std::remove_if(TypeVec.begin(), TypeVec.end(), [Largest](MVT OtherVT) { // Don't compare vector and non-vector types. |