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

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 8 16:36:12 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);
----------------
preames wrote:

This expression should just be IRBuilder::getTypeSize(IntIdxTy, TSize).

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


More information about the llvm-commits mailing list