@@ -353,16 +353,19 @@ RISCVGatherScatterLowering::determineBaseAndStride(Instruction *Ptr,
353
353
Value *Base = GEP->getPointerOperand ();
354
354
if (auto *BaseInst = dyn_cast<Instruction>(Base);
355
355
BaseInst && BaseInst->getType ()->isVectorTy ()) {
356
- auto [BaseBase, Stride] = determineBaseAndStride (BaseInst, Builder);
357
356
// If GEP's offset is scalar then we can add it to the base pointer's base.
358
357
auto IsScalar = [](Value *Idx) { return !Idx->getType ()->isVectorTy (); };
359
- if (BaseBase && all_of (GEP->indices (), IsScalar)) {
360
- Builder.SetInsertPoint (GEP);
361
- SmallVector<Value *> Indices (GEP->indices ());
362
- Value *OffsetBase =
363
- Builder.CreateGEP (GEP->getSourceElementType (), BaseBase, Indices, " " ,
364
- GEP->isInBounds ());
365
- return {OffsetBase, Stride};
358
+ if (all_of (GEP->indices (), IsScalar)) {
359
+ auto [BaseBase, Stride] = determineBaseAndStride (BaseInst, Builder);
360
+ if (BaseBase) {
361
+ Builder.SetInsertPoint (GEP);
362
+ SmallVector<Value *> Indices (GEP->indices ());
363
+ Value *OffsetBase =
364
+ Builder.CreateGEP (GEP->getSourceElementType (), BaseBase, Indices,
365
+ " " , GEP->isInBounds ());
366
+ OffsetBase->takeName (GEP);
367
+ return {OffsetBase, Stride};
368
+ }
366
369
}
367
370
}
368
371
0 commit comments