Lines Matching refs:GEP
132 Instruction *tryReassociateGEP(GetElementPtrInst *GEP);
140 GetElementPtrInst *tryReassociateGEPAtIndex(GetElementPtrInst *GEP,
144 GetElementPtrInst *tryReassociateGEPAtIndex(GetElementPtrInst *GEP,
174 bool requiresSignExtension(Value *Index, GetElementPtrInst *GEP);
302 static bool isGEPFoldable(GetElementPtrInst *GEP, in isGEPFoldable() argument
305 for (auto I = GEP->idx_begin(); I != GEP->idx_end(); ++I) in isGEPFoldable()
307 return TTI->getGEPCost(GEP->getSourceElementType(), GEP->getPointerOperand(), in isGEPFoldable()
311 Instruction *NaryReassociate::tryReassociateGEP(GetElementPtrInst *GEP) { in tryReassociateGEP() argument
313 if (isGEPFoldable(GEP, TTI)) in tryReassociateGEP()
316 gep_type_iterator GTI = gep_type_begin(*GEP); in tryReassociateGEP()
317 for (unsigned I = 1, E = GEP->getNumOperands(); I != E; ++I) { in tryReassociateGEP()
319 if (auto *NewGEP = tryReassociateGEPAtIndex(GEP, I - 1, *GTI)) { in tryReassociateGEP()
328 GetElementPtrInst *GEP) { in requiresSignExtension() argument
330 DL->getPointerSizeInBits(GEP->getType()->getPointerAddressSpace()); in requiresSignExtension()
335 NaryReassociate::tryReassociateGEPAtIndex(GetElementPtrInst *GEP, unsigned I, in tryReassociateGEPAtIndex() argument
337 Value *IndexToSplit = GEP->getOperand(I + 1); in tryReassociateGEPAtIndex()
342 if (isKnownNonNegative(ZExt->getOperand(0), *DL, 0, AC, GEP, DT)) in tryReassociateGEPAtIndex()
350 if (requiresSignExtension(IndexToSplit, GEP) && in tryReassociateGEPAtIndex()
351 computeOverflowForSignedAdd(AO, *DL, AC, GEP, DT) != in tryReassociateGEPAtIndex()
357 if (auto *NewGEP = tryReassociateGEPAtIndex(GEP, I, LHS, RHS, IndexedType)) in tryReassociateGEPAtIndex()
362 tryReassociateGEPAtIndex(GEP, I, RHS, LHS, IndexedType)) in tryReassociateGEPAtIndex()
370 GetElementPtrInst *GEP, unsigned I, Value *LHS, Value *RHS, in tryReassociateGEPAtIndex() argument
375 for (auto Index = GEP->idx_begin(); Index != GEP->idx_end(); ++Index) in tryReassociateGEPAtIndex()
379 if (isKnownNonNegative(LHS, *DL, 0, AC, GEP, DT) && in tryReassociateGEPAtIndex()
381 DL->getTypeSizeInBits(GEP->getOperand(I)->getType())) { in tryReassociateGEPAtIndex()
387 SE->getZeroExtendExpr(IndexExprs[I], GEP->getOperand(I)->getType()); in tryReassociateGEPAtIndex()
390 GEP->getSourceElementType(), SE->getSCEV(GEP->getPointerOperand()), in tryReassociateGEPAtIndex()
391 IndexExprs, GEP->isInBounds()); in tryReassociateGEPAtIndex()
393 Value *Candidate = findClosestMatchingDominator(CandidateExpr, GEP); in tryReassociateGEPAtIndex()
397 IRBuilder<> Builder(GEP); in tryReassociateGEPAtIndex()
401 Candidate = Builder.CreateBitOrPointerCast(Candidate, GEP->getType()); in tryReassociateGEPAtIndex()
402 assert(Candidate->getType() == GEP->getType()); in tryReassociateGEPAtIndex()
406 Type *ElementType = GEP->getResultElementType(); in tryReassociateGEPAtIndex()
426 Type *IntPtrTy = DL->getIntPtrType(GEP->getType()); in tryReassociateGEPAtIndex()
435 NewGEP->setIsInBounds(GEP->isInBounds()); in tryReassociateGEPAtIndex()
436 NewGEP->takeName(GEP); in tryReassociateGEPAtIndex()