From 8cc053e6765aed2437eac8395c8b330d4b7c609e Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <kparzysz@codeaurora.org>
Date: Sun, 15 Oct 2017 15:39:56 +0000
Subject: [PATCH] [TableGen] Remove error checks incorrectly failing on
 non-error conditions

In type inference, an empty type set for a specific hw mode is not an
error. In earlier stages of the design it was, but having to use non-
parameterized types with target intrinsics necessarily led to type
contradictions: since the intrinsics used specific types, they were
only valid for a specific hw mode, and the resulting type set for other
modes ended up empty. To accommodate the existence of such intrinsics
individual type sets were allowed to be empty as long as not all sets
were empty.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315858 91177308-0d34-0410-b5e6-96231b3b80d8
---
 utils/TableGen/CodeGenDAGPatterns.cpp | 55 +++------------------------
 1 file changed, 6 insertions(+), 49 deletions(-)

diff --git a/utils/TableGen/CodeGenDAGPatterns.cpp b/utils/TableGen/CodeGenDAGPatterns.cpp
index 163977f8e57..f6ef35a68c6 100644
--- a/utils/TableGen/CodeGenDAGPatterns.cpp
+++ b/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -514,48 +514,26 @@ bool TypeInfer::EnforceSmallerThan(TypeSetByHwMode &Small,
     // MinS = min scalar in Small, remove all scalars from Big that are
     // smaller-or-equal than MinS.
     auto MinS = min_if(S.begin(), S.end(), isScalar, LT);
-    if (MinS != S.end()) {
+    if (MinS != S.end())
       Changed |= berase_if(B, std::bind(LE, std::placeholders::_1, *MinS));
-      if (B.empty()) {
-        TP.error("Type contradiction in " +
-                 Twine(__func__) + ":" + Twine(__LINE__));
-        return Changed;
-      }
-    }
+
     // MaxS = max scalar in Big, remove all scalars from Small that are
     // larger than MaxS.
     auto MaxS = max_if(B.begin(), B.end(), isScalar, LT);
-    if (MaxS != B.end()) {
+    if (MaxS != B.end())
       Changed |= berase_if(S, std::bind(LE, *MaxS, std::placeholders::_1));
-      if (B.empty()) {
-        TP.error("Type contradiction in " +
-                 Twine(__func__) + ":" + Twine(__LINE__));
-        return Changed;
-      }
-    }
 
     // MinV = min vector in Small, remove all vectors from Big that are
     // smaller-or-equal than MinV.
     auto MinV = min_if(S.begin(), S.end(), isVector, LT);
-    if (MinV != S.end()) {
+    if (MinV != S.end())
       Changed |= berase_if(B, std::bind(LE, std::placeholders::_1, *MinV));
-      if (B.empty()) {
-        TP.error("Type contradiction in " +
-                 Twine(__func__) + ":" + Twine(__LINE__));
-        return Changed;
-      }
-    }
+
     // MaxV = max vector in Big, remove all vectors from Small that are
     // larger than MaxV.
     auto MaxV = max_if(B.begin(), B.end(), isVector, LT);
-    if (MaxV != B.end()) {
+    if (MaxV != B.end())
       Changed |= berase_if(S, std::bind(LE, *MaxV, std::placeholders::_1));
-      if (B.empty()) {
-        TP.error("Type contradiction in " +
-                 Twine(__func__) + ":" + Twine(__LINE__));
-        return Changed;
-      }
-    }
   }
 
   return Changed;
@@ -600,12 +578,6 @@ bool TypeInfer::EnforceVectorEltTypeIs(TypeSetByHwMode &Vec,
     // Remove from E all (scalar) types, for which there is no corresponding
     // type in V.
     Changed |= berase_if(E, [&VT](MVT T) -> bool { return !VT.count(T); });
-
-    if (V.empty() || E.empty()) {
-      TP.error("Type contradiction in " +
-               Twine(__func__) + ":" + Twine(__LINE__));
-      return Changed;
-    }
   }
 
   return Changed;
@@ -666,27 +638,12 @@ bool TypeInfer::EnforceVectorSubVectorTypeIs(TypeSetByHwMode &Vec,
     TypeSetByHwMode::SetType &V = Vec.get(M);
 
     Changed |= berase_if(S, isScalar);
-    if (S.empty()) {
-      TP.error("Type contradiction in " +
-               Twine(__func__) + ":" + Twine(__LINE__));
-      return Changed;
-    }
 
     // Erase all types from S that are not sub-vectors of a type in V.
     Changed |= berase_if(S, std::bind(NoSubV, V, std::placeholders::_1));
-    if (S.empty()) {
-      TP.error("Type contradiction in " +
-               Twine(__func__) + ":" + Twine(__LINE__));
-      return Changed;
-    }
 
     // Erase all types from V that are not super-vectors of a type in S.
     Changed |= berase_if(V, std::bind(NoSupV, S, std::placeholders::_1));
-    if (V.empty()) {
-      TP.error("Type contradiction in " +
-               Twine(__func__) + ":" + Twine(__LINE__));
-      return Changed;
-    }
   }
 
   return Changed;
-- 
2.40.0