[llvm] [DA] Rewrite BanerjeeMIV test with safe APInt interval arithmetic (PR #207662)
Ryotaro Kasuga via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 6 06:42:43 PDT 2026
================
@@ -1922,36 +1922,167 @@ bool DependenceInfo::gcdMIVtest(const SCEV *Src, const SCEV *Dst,
}
//===----------------------------------------------------------------------===//
+
+namespace {
+struct BanerjeeInterval {
+ std::optional<APInt> Lower;
+ std::optional<APInt> Upper;
+
+ BanerjeeInterval(std::optional<APInt> Lower, std::optional<APInt> Upper)
+ : Lower(std::move(Lower)), Upper(std::move(Upper)) {}
+};
+} // namespace
+
+static APInt signedMin(const APInt &A, const APInt &B) {
+ return A.slt(B) ? A : B;
+}
+
+static APInt signedMax(const APInt &A, const APInt &B) {
+ return A.sgt(B) ? A : B;
+}
+
+static BanerjeeInterval addIntervals(const BanerjeeInterval &A,
+ const BanerjeeInterval &B) {
+ std::optional<APInt> Lower;
+ std::optional<APInt> Upper;
+ if (A.Lower && B.Lower)
+ Lower = *A.Lower + *B.Lower;
----------------
kasuga-fj wrote:
What happens if this addition overflows? Same applies to all other APInt arithmetics.
https://github.com/llvm/llvm-project/pull/207662
More information about the llvm-commits
mailing list