Lines Matching refs:GEP
328 static bool isGEPFoldable(GetElementPtrInst *GEP, in isGEPFoldable() argument
330 SmallVector<const Value *, 4> Indices(GEP->indices()); in isGEPFoldable()
331 return TTI->getGEPCost(GEP->getSourceElementType(), GEP->getPointerOperand(), in isGEPFoldable()
335 Instruction *NaryReassociatePass::tryReassociateGEP(GetElementPtrInst *GEP) { in tryReassociateGEP() argument
337 if (isGEPFoldable(GEP, TTI)) in tryReassociateGEP()
340 gep_type_iterator GTI = gep_type_begin(*GEP); in tryReassociateGEP()
341 for (unsigned I = 1, E = GEP->getNumOperands(); I != E; ++I, ++GTI) { in tryReassociateGEP()
343 if (auto *NewGEP = tryReassociateGEPAtIndex(GEP, I - 1, in tryReassociateGEP()
353 GetElementPtrInst *GEP) { in requiresSignExtension() argument
355 DL->getPointerSizeInBits(GEP->getType()->getPointerAddressSpace()); in requiresSignExtension()
360 NaryReassociatePass::tryReassociateGEPAtIndex(GetElementPtrInst *GEP, in tryReassociateGEPAtIndex() argument
362 Value *IndexToSplit = GEP->getOperand(I + 1); in tryReassociateGEPAtIndex()
367 if (isKnownNonNegative(ZExt->getOperand(0), *DL, 0, AC, GEP, DT)) in tryReassociateGEPAtIndex()
375 if (requiresSignExtension(IndexToSplit, GEP) && in tryReassociateGEPAtIndex()
376 computeOverflowForSignedAdd(AO, *DL, AC, GEP, DT) != in tryReassociateGEPAtIndex()
382 if (auto *NewGEP = tryReassociateGEPAtIndex(GEP, I, LHS, RHS, IndexedType)) in tryReassociateGEPAtIndex()
387 tryReassociateGEPAtIndex(GEP, I, RHS, LHS, IndexedType)) in tryReassociateGEPAtIndex()
395 NaryReassociatePass::tryReassociateGEPAtIndex(GetElementPtrInst *GEP, in tryReassociateGEPAtIndex() argument
401 for (Use &Index : GEP->indices()) in tryReassociateGEPAtIndex()
405 if (isKnownNonNegative(LHS, *DL, 0, AC, GEP, DT) && in tryReassociateGEPAtIndex()
407 DL->getTypeSizeInBits(GEP->getOperand(I)->getType()).getFixedSize()) { in tryReassociateGEPAtIndex()
413 SE->getZeroExtendExpr(IndexExprs[I], GEP->getOperand(I)->getType()); in tryReassociateGEPAtIndex()
415 const SCEV *CandidateExpr = SE->getGEPExpr(cast<GEPOperator>(GEP), in tryReassociateGEPAtIndex()
418 Value *Candidate = findClosestMatchingDominator(CandidateExpr, GEP); in tryReassociateGEPAtIndex()
422 IRBuilder<> Builder(GEP); in tryReassociateGEPAtIndex()
426 Candidate = Builder.CreateBitOrPointerCast(Candidate, GEP->getType()); in tryReassociateGEPAtIndex()
427 assert(Candidate->getType() == GEP->getType()); in tryReassociateGEPAtIndex()
431 Type *ElementType = GEP->getResultElementType(); in tryReassociateGEPAtIndex()
451 Type *IntPtrTy = DL->getIntPtrType(GEP->getType()); in tryReassociateGEPAtIndex()
459 Builder.CreateGEP(GEP->getResultElementType(), Candidate, RHS)); in tryReassociateGEPAtIndex()
460 NewGEP->setIsInBounds(GEP->isInBounds()); in tryReassociateGEPAtIndex()
461 NewGEP->takeName(GEP); in tryReassociateGEPAtIndex()