diff options
author | Craig Topper <craig.topper@intel.com> | 2017-07-07 19:56:23 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2017-07-07 19:56:23 +0000 |
commit | 77235d345eb11a3705fbb93196eb7817734402a9 (patch) | |
tree | d939ab5862423b3307855131939c99b6c2e1d68c | |
parent | 5a06c2264b2096224dc0786e2e6d33f2378c3b4c (diff) | |
download | bcm5719-llvm-77235d345eb11a3705fbb93196eb7817734402a9.tar.gz bcm5719-llvm-77235d345eb11a3705fbb93196eb7817734402a9.zip |
[PatternMatch] Implemenet m_SignMask using Constant::isMinSignedValue instead of doing splat detection and analyzing the resulting APInt.
llvm-svn: 307433
-rw-r--r-- | llvm/include/llvm/IR/PatternMatch.h | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/llvm/include/llvm/IR/PatternMatch.h b/llvm/include/llvm/IR/PatternMatch.h index 4b03063a6a9..acb89521164 100644 --- a/llvm/include/llvm/IR/PatternMatch.h +++ b/llvm/include/llvm/IR/PatternMatch.h @@ -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(); } }; |