[llvm] [LV] Use SCEVPatternMatch to improve code (NFC) (PR #154568)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 20 09:41:08 PDT 2025
================
@@ -107,14 +107,25 @@ struct specificscev_ty {
/// Match if we have a specific specified SCEV.
inline specificscev_ty m_scev_Specific(const SCEV *S) { return S; }
-struct is_specific_cst {
- uint64_t CV;
- is_specific_cst(uint64_t C) : CV(C) {}
- bool isValue(const APInt &C) const { return C == CV; }
+template <typename ITy> struct is_specific_cst {
+ ITy CV;
+ is_specific_cst(ITy C) : CV(C) {}
+ bool isValue(const APInt &C) const {
+ if constexpr (std::is_unsigned_v<ITy>)
+ return C.tryZExtValue() == CV;
+ return C.trySExtValue() == CV;
+ }
----------------
artagnon wrote:
As an alternative, I could template'ize APInt::operator==, but I'm not sure if that's desirable.
https://github.com/llvm/llvm-project/pull/154568
More information about the llvm-commits
mailing list