[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:27:44 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.
----------------
nikic wrote:
Okay, looking a bit further I guess you kind of already do this, just with checks of the IsVScale flag. I think I'd still prefer a sentinel value, to make sure we "crash and burn" if we fail to handle it somewhere, instead of silently miscompiling. This should also allow you to do something actually useful for the vscale intrinsinc handling in LinearExpression, as we would ensure that the same value gets used for `vscale x` and the intrinsic.
https://github.com/llvm/llvm-project/pull/69152
More information about the llvm-commits
mailing list