aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Support/PatternMatch.h
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2010-11-17 18:52:15 +0000
committerDuncan Sands <baldrick@free.fr>2010-11-17 18:52:15 +0000
commit2b749870d0488c3b049edf5d0c8875f56f5b1bed (patch)
tree18afe3a1c1876a3a43e139d1b39e2e54ec780f60 /include/llvm/Support/PatternMatch.h
parent89e14c7579d9351da2e39a85703882bac3a83980 (diff)
Move some those Xor simplifications which don't require creating new
instructions out of InstCombine and into InstructionSimplify. While there, introduce an m_AllOnes pattern to simplify matching with integers and vectors with all bits equal to one. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119536 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/PatternMatch.h')
-rw-r--r--include/llvm/Support/PatternMatch.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h
index bee6768637..8b5812141d 100644
--- a/include/llvm/Support/PatternMatch.h
+++ b/include/llvm/Support/PatternMatch.h
@@ -96,9 +96,23 @@ struct one_ty {
}
};
-/// m_One() - Match a an integer 1.
+/// m_One() - Match an integer 1.
inline one_ty m_One() { return one_ty(); }
+struct all_ones_ty {
+ template<typename ITy>
+ bool match(ITy *V) {
+ if (const ConstantInt *C = dyn_cast<ConstantInt>(V))
+ return C->isAllOnesValue();
+ if (const ConstantVector *C = dyn_cast<ConstantVector>(V))
+ return C->isAllOnesValue();
+ return false;
+ }
+};
+
+/// m_AllOnes() - Match an integer or vector with all bits set to true.
+inline all_ones_ty m_AllOnes() { return all_ones_ty(); }
+
template<typename Class>
struct bind_ty {