[all-commits] [llvm/llvm-project] 73eb81: [DA] Rewrite BanerjeeMIV test with safe APInt inte...

Ruoyu Qiu via All-commits all-commits at lists.llvm.org
Thu Jul 16 19:47:59 PDT 2026


  Branch: refs/heads/users/cabbaken/rewriteBanerjeeTest
  Home:   https://github.com/llvm/llvm-project
  Commit: 73eb817a9a950c8be53ca2fde16b5772d02d278b
      https://github.com/llvm/llvm-project/commit/73eb817a9a950c8be53ca2fde16b5772d02d278b
  Author: Ruoyu Qiu <cabbaken at outlook.com>
  Date:   2026-07-17 (Fri, 17 Jul 2026)

  Changed paths:
    M llvm/include/llvm/Analysis/DependenceAnalysis.h
    M llvm/lib/Analysis/DependenceAnalysis.cpp
    M llvm/test/Analysis/DependenceAnalysis/PR51512.ll
    M llvm/test/Analysis/DependenceAnalysis/banerjee-overflow.ll
    M llvm/test/Analysis/DependenceAnalysis/gcd-miv-overflow.ll

  Log Message:
  -----------
  [DA] Rewrite BanerjeeMIV test with safe APInt interval arithmetic

The old banerjeeMIVtest computed inequality bounds using SCEV
arithmetic on 64-bit integers. Intermediate operations like
$(A^{-} - B^{+}) \times Iterations$ could overflow i64 even when all individual
coefficients and loop bounds fit, producing unsound results.

Replace the symbolic bound machinery with a self-contained APInt
interval arithmetic implementation. Key design decisions:

- BanerjeeInterval holds [Lower, Upper] signed-inclusive bounds.
  Operations use APInt arithmetic at WideBits, chosen to guarantee no
  intermediate overflow:
  $$
    WideBits = max(8, 2 \times BaseBits + MaxLevels + 8)
  $$
  This is provably sufficient, each term product needs at most `2 \times BaseBits + 1`
  bits, and summing across MaxLevels terms needs at most ceil($\log_2 (MaxLevels)$)
  extra bits.

- Only constant affine expressions are handled. `CollectConstantAffine`
  requires nsw on every SCEVAddRecExpr and a SCEVConstant for both the
  step recurrence and the backedge-taken count.
  Symbolic cases bail out conservatively.

Fixes the FIXME in gcdmiv_delta_ovfl2.ll: the old code could not
detect the dependence because intermediate SCEV subtraction of
coefficients near INT64_MIN and INT64_MAX overflowed i64. The new code
computes correct bounds at WideBits >= 138.

Adds a test in banerjee-overflow.ll for single-iteration loops and
updates PR51512.ll for the more precise direction refinement.

Signed-off-by: Ruoyu Qiu <cabbaken at outlook.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list