[llvm] [BasicAA] Add Vscale GEP decomposition on variable index (PR #69152)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 10 07:13:32 PST 2024


================
@@ -357,13 +359,20 @@ struct LinearExpression {
 
 /// Analyzes the specified value as a linear expression: "A*V + B", where A and
 /// B are constant integers.
-static LinearExpression GetLinearExpression(
-    const CastedValue &Val,  const DataLayout &DL, unsigned Depth,
-    AssumptionCache *AC, DominatorTree *DT) {
+static LinearExpression GetLinearExpression(const CastedValue &Val,
+                                            const DataLayout &DL,
+                                            unsigned Depth, AssumptionCache *AC,
+                                            DominatorTree *DT) {
   // Limit our recursion depth.
   if (Depth == 6)
     return Val;
 
+  // If llvm.vscale is matched, set linear expression with scale 1 and offset 0
+  if (match(Val.V, m_VScale())) {
+    return LinearExpression(Val, APInt(Val.getBitWidth(), 1),
+                            APInt(Val.getBitWidth(), 0), true);
+  }
----------------
nikic wrote:

I don't understand the purpose of this check. Doesn't this do the same as the default case, at least as implemented?

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


More information about the llvm-commits mailing list