[llvm] [LV] Use SCEVPatternMatch to improve code (NFC) (PR #154568)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 21 03:57:40 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;
----------------
fhahn wrote:
Could we leave `m_scev_SpecificInt` as-is, and just add a seperate matcher that makes clear we are matching the sign-extended value?
https://github.com/llvm/llvm-project/pull/154568
More information about the llvm-commits
mailing list