aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Support/PatternMatch.h
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2011-02-01 08:39:12 +0000
committerDuncan Sands <baldrick@free.fr>2011-02-01 08:39:12 +0000
commit7681c6da606efcc392f76b8acea8301cb5fc7a0a (patch)
treec2e5253bcd443580cffc64f2698568c2d3aa3d9d /include/llvm/Support/PatternMatch.h
parente47023d543aecb8ca558721a0259d83ab2b016a3 (diff)
Have m_One also match constant vectors for which every element is 1.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124655 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/PatternMatch.h')
-rw-r--r--include/llvm/Support/PatternMatch.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h
index 322ed436c9..b203c1ee1a 100644
--- a/include/llvm/Support/PatternMatch.h
+++ b/include/llvm/Support/PatternMatch.h
@@ -90,13 +90,16 @@ inline zero_ty m_Zero() { return zero_ty(); }
struct one_ty {
template<typename ITy>
bool match(ITy *V) {
- if (const ConstantInt *C = dyn_cast<ConstantInt>(V))
- return C->isOne();
+ if (const ConstantInt *CI = dyn_cast<ConstantInt>(V))
+ return CI->isOne();
+ if (const ConstantVector *CV = dyn_cast<ConstantVector>(V))
+ if (ConstantInt *CI = cast_or_null<ConstantInt>(CV->getSplatValue()))
+ return CI->isOne();
return false;
}
};
-/// m_One() - Match an integer 1.
+/// m_One() - Match an integer 1 or a vector with all elements equal to 1.
inline one_ty m_One() { return one_ty(); }
struct all_ones_ty {