]> granicus.if.org Git - llvm/commitdiff
[PatternMatch] Implemenet m_SignMask using Constant::isMinSignedValue instead of...
authorCraig Topper <craig.topper@intel.com>
Fri, 7 Jul 2017 19:56:23 +0000 (19:56 +0000)
committerCraig Topper <craig.topper@intel.com>
Fri, 7 Jul 2017 19:56:23 +0000 (19:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307433 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/PatternMatch.h

index 4b03063a6a98d64edc6605284233c40826cf0735..acb895211644192c89b211653476f68a9fe50a1b 100644 (file)
@@ -204,6 +204,17 @@ struct match_all_ones {
 /// \brief Match an integer or vector with all bits set to true.
 inline match_all_ones m_AllOnes() { return match_all_ones(); }
 
+struct match_sign_mask {
+  template <typename ITy> bool match(ITy *V) {
+    if (const auto *C = dyn_cast<Constant>(V))
+      return C->isMinSignedValue();
+    return false;
+  }
+};
+
+/// \brief Match an integer or vector with only the sign bit(s) set.
+inline match_sign_mask m_SignMask() { return match_sign_mask(); }
+
 struct apint_match {
   const APInt *&Res;
 
@@ -287,16 +298,6 @@ template <typename Predicate> struct api_pred_ty : public Predicate {
   }
 };
 
-struct is_sign_mask {
-  bool isValue(const APInt &C) { return C.isSignMask(); }
-};
-
-/// \brief Match an integer or vector with only the sign bit(s) set.
-inline cst_pred_ty<is_sign_mask> m_SignMask() {
-  return cst_pred_ty<is_sign_mask>();
-}
-inline api_pred_ty<is_sign_mask> m_SignMask(const APInt *&V) { return V; }
-
 struct is_power2 {
   bool isValue(const APInt &C) { return C.isPowerOf2(); }
 };