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

David Green via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 14 14:16:20 PST 2024


================
@@ -663,22 +664,56 @@ BasicAAResult::DecomposeGEPExpression(const Value *V, const DataLayout &DL,
       unsigned Width = Index->getType()->getIntegerBitWidth();
       unsigned SExtBits = IndexSize > Width ? IndexSize - Width : 0;
       unsigned TruncBits = IndexSize < Width ? Width - IndexSize : 0;
-      LinearExpression LE = GetLinearExpression(
-          CastedValue(Index, 0, SExtBits, TruncBits), DL, 0, AC, DT);
+      // Scalable GEP decomposition
+      // Allow Scalable GEP to be decomposed in the case of
+      //    1. getelementptr <4 x vscale x i32> with 1st index as a constant
+      //    2. Index which have a leaf of @llvm.vscale
+      // In both cases, essentially CastedValue of VariableGEPIndex is Vscale,
+      // however in the 1st case, CastedValue is of type constant, hence another
+      // flag in VariableGEPIndex is created in this case, IsVScale If GEP is
+      // Scalable type, e.g. <4 x vscale x i32>, the first index will have
+      // vscale as a variable index, create a LE in this case.
----------------
davemgreen wrote:

I think that sounds like a good idea, but it is currently using the value for the bitwidth so may need some other way to represent that.

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


More information about the llvm-commits mailing list