1515#define LLVM_ANALYSIS_SCALAREVOLUTIONPATTERNMATCH_H
1616
1717#include " llvm/Analysis/ScalarEvolutionExpressions.h"
18+ #include " llvm/IR/PatternMatch.h"
1819
1920namespace llvm {
2021namespace SCEVPatternMatch {
@@ -24,34 +25,19 @@ bool match(const SCEV *S, const Pattern &P) {
2425 return P.match (S);
2526}
2627
27- // / Match a specified integer value. \p BitWidth optionally specifies the
28- // / bitwidth the matched constant must have. If it is 0, the matched constant
29- // / can have any bitwidth.
30- template <unsigned BitWidth = 0 > struct specific_intval {
31- APInt Val;
28+ struct specific_intval64 : public PatternMatch ::specific_intval64<false > {
29+ specific_intval64 (uint64_t V) : PatternMatch::specific_intval64<false >(V) {}
3230
33- specific_intval (APInt V) : Val(std::move(V)) {}
34-
35- bool match (const SCEV *S) const {
36- const auto *C = dyn_cast<SCEVConstant>(S);
37- if (!C)
38- return false ;
39-
40- if (BitWidth != 0 && C->getAPInt ().getBitWidth () != BitWidth)
41- return false ;
42- return APInt::isSameValue (C->getAPInt (), Val);
31+ bool match (const SCEV *S) {
32+ auto *Cast = dyn_cast<SCEVConstant>(S);
33+ return Cast &&
34+ PatternMatch::specific_intval64<false >::match (Cast->getValue ());
4335 }
4436};
4537
46- inline specific_intval<0 > m_scev_Zero () {
47- return specific_intval<0 >(APInt (64 , 0 ));
48- }
49- inline specific_intval<0 > m_scev_One () {
50- return specific_intval<0 >(APInt (64 , 1 ));
51- }
52- inline specific_intval<0 > m_scev_MinusOne () {
53- return specific_intval<0 >(APInt (64 , -1 ));
54- }
38+ inline specific_intval64 m_scev_Zero () { return specific_intval64 (0 ); }
39+ inline specific_intval64 m_scev_One () { return specific_intval64 (1 ); }
40+ inline specific_intval64 m_scev_MinusOne () { return specific_intval64 (-1 ); }
5541
5642} // namespace SCEVPatternMatch
5743} // namespace llvm
0 commit comments