[llvm] [BasicAA] Refactor offset-based heuristics in `aliasGEP`, unify style (NFC) (PR #218687)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 25 07:38:04 PDT 2026


================
@@ -116,6 +117,19 @@ class BasicAAResult : public AAResultBase {
   DecomposeGEPExpression(const Value *V, const DataLayout &DL,
                          AssumptionCache *AC, DominatorTree *DT);
 
+  /// Analyze the variable indices of a decomposed GEP, computing the GCD
+  /// that each Scale*V term is a multiple of, and an approximate range of
+  /// possible total offsets.
+  VariableGEPOffsetInfo analyzeVariableOffsets(const DecomposedGEP &GEP,
+                                               DominatorTree *DT);
+
+  /// Try to determine the range of values for VarIndex such that
+  /// VarIndex <= -MinAbsVarIndex || MinAbsVarIndex <= VarIndex, thus
+  /// establishing a minimum absolute value of the variable offset.
+  std::optional<APInt> computeMinAbsVarIndexHeuristic(const DecomposedGEP &GEP,
----------------
nikic wrote:

```suggestion
  std::optional<APInt> computeMinAbsVarIndex(const DecomposedGEP &GEP,
```
Possibly s/Index/Offset as well. I'd expect the function name to describe the meaning of the return value here, which is the minimum absolute value of the variable offset.

Do we need std::optional?

https://github.com/llvm/llvm-project/pull/218687


More information about the llvm-commits mailing list