[llvm] [InstCombine] Handle scalable geps in EmitGEPOffset (PR #71565)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 7 10:29:41 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);
----------------
david-arm wrote:

It looks like `ScaleC` could possibly be a VectorType judging from the `CreateVectorSplat` call above. Do we need a test for this?

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


More information about the llvm-commits mailing list