[llvm] r307433 - [PatternMatch] Implemenet m_SignMask using Constant::isMinSignedValue instead of doing splat detection and analyzing the resulting APInt.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 7 12:56:23 PDT 2017
Author: ctopper
Date: Fri Jul 7 12:56:23 2017
New Revision: 307433
URL: http://llvm.org/viewvc/llvm-project?rev=307433&view=rev
Log:
[PatternMatch] Implemenet m_SignMask using Constant::isMinSignedValue instead of doing splat detection and analyzing the resulting APInt.
Modified:
llvm/trunk/include/llvm/IR/PatternMatch.h
Modified: llvm/trunk/include/llvm/IR/PatternMatch.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/PatternMatch.h?rev=307433&r1=307432&r2=307433&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/PatternMatch.h (original)
+++ llvm/trunk/include/llvm/IR/PatternMatch.h Fri Jul 7 12:56:23 2017
@@ -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
}
};
-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(); }
};
More information about the llvm-commits
mailing list