Lines Matching defs:GEP
328 static bool isGEPFoldable(GetElementPtrInst *GEP,
330 SmallVector<const Value *, 4> Indices(GEP->indices());
331 return TTI->getGEPCost(GEP->getSourceElementType(), GEP->getPointerOperand(),
335 Instruction *NaryReassociatePass::tryReassociateGEP(GetElementPtrInst *GEP) {
336 // Not worth reassociating GEP if it is foldable.
337 if (isGEPFoldable(GEP, TTI))
340 gep_type_iterator GTI = gep_type_begin(*GEP);
341 for (unsigned I = 1, E = GEP->getNumOperands(); I != E; ++I, ++GTI) {
343 if (auto *NewGEP = tryReassociateGEPAtIndex(GEP, I - 1,
353 GetElementPtrInst *GEP) {
355 DL->getIndexSizeInBits(GEP->getType()->getPointerAddressSpace());
360 NaryReassociatePass::tryReassociateGEPAtIndex(GetElementPtrInst *GEP,
362 SimplifyQuery SQ(*DL, DT, AC, GEP);
363 Value *IndexToSplit = GEP->getOperand(I + 1);
376 if (requiresSignExtension(IndexToSplit, GEP) &&
382 if (auto *NewGEP = tryReassociateGEPAtIndex(GEP, I, LHS, RHS, IndexedType))
387 tryReassociateGEPAtIndex(GEP, I, RHS, LHS, IndexedType))
395 NaryReassociatePass::tryReassociateGEPAtIndex(GetElementPtrInst *GEP,
398 // Look for GEP's closest dominator that has the same SCEV as GEP except that
401 for (Use &Index : GEP->indices())
405 if (isKnownNonNegative(LHS, SimplifyQuery(*DL, DT, AC, GEP)) &&
407 DL->getTypeSizeInBits(GEP->getOperand(I)->getType())
414 SE->getZeroExtendExpr(IndexExprs[I], GEP->getOperand(I)->getType());
416 const SCEV *CandidateExpr = SE->getGEPExpr(cast<GEPOperator>(GEP),
419 Value *Candidate = findClosestMatchingDominator(CandidateExpr, GEP);
423 IRBuilder<> Builder(GEP);
424 // Candidate should have the same pointer type as GEP.
425 assert(Candidate->getType() == GEP->getType());
429 Type *ElementType = GEP->getResultElementType();
432 // GEP, the size of the type at the I-th index (IndexedSize) is not
449 Type *PtrIdxTy = DL->getIndexType(GEP->getType());
457 Builder.CreateGEP(GEP->getResultElementType(), Candidate, RHS));
458 NewGEP->setIsInBounds(GEP->isInBounds());
459 NewGEP->takeName(GEP);