[llvm] [InstCombine] Handle scalable geps in EmitGEPOffset (PR #71565)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 8 07:50:29 PST 2023
================
@@ -70,10 +71,12 @@ Value *llvm::emitGEPOffset(IRBuilderBase *Builder, const DataLayout &DL,
// Convert to correct type.
if (Op->getType() != IntIdxTy)
Op = Builder->CreateIntCast(Op, IntIdxTy, true, Op->getName() + ".c");
- if (Size != 1) {
+ if (Size != 1 || TSize.isScalable()) {
// We'll let instcombine(mul) convert this to a shl if possible.
- Op = Builder->CreateMul(Op, ConstantInt::get(IntIdxTy, Size),
- GEP->getName() + ".idx", false /*NUW*/,
+ auto *ScaleC = ConstantInt::get(IntIdxTy, Size);
+ Value *Scale =
+ !TSize.isScalable() ? ScaleC : Builder->CreateVScale(ScaleC);
----------------
davemgreen wrote:
Thanks for the suggestion. It looks like the above CreateVectorSplat wouldn't handle scalable vectors either. That is actually a different form of scalable vector, but I'll try and address that in a separate patch.
https://github.com/llvm/llvm-project/pull/71565
More information about the llvm-commits
mailing list