[llvm] r254589 - [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
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 2 21:57:38 PST 2015
Author: ctopper
Date: Wed Dec 2 23:57:37 2015
New Revision: 254589
URL: http://llvm.org/viewvc/llvm-project?rev=254589&view=rev
Log:
[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
Modified:
llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=254589&r1=254588&r2=254589&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Wed Dec 2 23:57:37 2015
@@ -388,7 +388,13 @@ bool EEVT::TypeSet::EnforceSmallerThan(E
// 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(E
// 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.
More information about the llvm-commits
mailing list