[llvm] [BasicAA] Analyze constant offsets through select (PR #218203)

via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 22 22:47:20 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- llvm/lib/Analysis/BasicAliasAnalysis.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index fb753fae4..99d04993c 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -2023,17 +2023,14 @@ bool BasicAAResult::constantOffsetHeuristic(const DecomposedGEP &GEP,
   // distance from the other index. This preserves correlations such as
   // select(x + 1, x + 2) versus x + 3 that range analysis loses.
   auto IsNoAlias = [&](const Value *V0, const Value *V1) {
-    LinearExpression E0 =
-        GetLinearExpression(CastedValue(V0), DL, 0, AC, DT);
-    LinearExpression E1 =
-        GetLinearExpression(CastedValue(V1), DL, 0, AC, DT);
+    LinearExpression E0 = GetLinearExpression(CastedValue(V0), DL, 0, AC, DT);
+    LinearExpression E1 = GetLinearExpression(CastedValue(V1), DL, 0, AC, DT);
     if (E0.Scale != E1.Scale || !E0.Val.hasSameCastsAs(E1.Val) ||
         !isValueEqualInPotentialCycles(E0.Val.V, E1.Val.V, AAQI))
       return false;
 
     APInt Scale = Var0.IsNegated ? -Var0.Scale : Var0.Scale;
-    APInt IndexDiff =
-        (E0.Offset - E1.Offset).sextOrTrunc(Scale.getBitWidth());
+    APInt IndexDiff = (E0.Offset - E1.Offset).sextOrTrunc(Scale.getBitWidth());
     APInt Diff = GEP.Offset + IndexDiff * Scale;
     return Diff.isNegative() ? (-Diff).uge(V1Size) : Diff.uge(V2Size);
   };

``````````

</details>


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


More information about the llvm-commits mailing list