summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2019-07-25 13:34:24 +0000
committerRoman Lebedev <lebedev.ri@gmail.com>2019-07-25 13:34:24 +0000
commit9f88fef51a770bf664089e26a7feded2afb15607 (patch)
tree0013145aa440ad2f86af863e0e291014e7d4aca9 /llvm/include
parent6df3fc543303bf6755474b0c9ec669e67eef56cc (diff)
downloadbcm5719-llvm-9f88fef51a770bf664089e26a7feded2afb15607.tar.gz
bcm5719-llvm-9f88fef51a770bf664089e26a7feded2afb15607.zip
[IR][PatternMatch] Introduce m_NegatedPower2() matcher
Summary: It is a good idea to do as much matching inside of `match()` as possible. If some checking is done afterwards, and we don't fold because of it, chances are we may have missed some commutative pattern. Reviewers: spatel, craig.topper, RKSimon Reviewed By: spatel, RKSimon Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64038 llvm-svn: 367017
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/IR/PatternMatch.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/include/llvm/IR/PatternMatch.h b/llvm/include/llvm/IR/PatternMatch.h
index f39678347d3..9d51bcd5d71 100644
--- a/llvm/include/llvm/IR/PatternMatch.h
+++ b/llvm/include/llvm/IR/PatternMatch.h
@@ -411,6 +411,18 @@ inline api_pred_ty<is_power2> m_Power2(const APInt *&V) {
return V;
}
+struct is_negated_power2 {
+ bool isValue(const APInt &C) { return (-C).isPowerOf2(); }
+};
+/// Match a integer or vector negated power-of-2.
+/// For vectors, this includes constants with undefined elements.
+inline cst_pred_ty<is_negated_power2> m_NegatedPower2() {
+ return cst_pred_ty<is_negated_power2>();
+}
+inline api_pred_ty<is_negated_power2> m_NegatedPower2(const APInt *&V) {
+ return V;
+}
+
struct is_power2_or_zero {
bool isValue(const APInt &C) { return !C || C.isPowerOf2(); }
};
OpenPOWER on IntegriCloud