Lines Matching defs:GEP

145 Instruction *InstCombiner::foldCmpLoadFromIndexedGlobal(GetElementPtrInst *GEP,
161 // Require: GEP GV, 0, i {{, constant indices}}
162 if (GEP->getNumOperands() < 3 ||
163 !isa<ConstantInt>(GEP->getOperand(1)) ||
164 !cast<ConstantInt>(GEP->getOperand(1))->isZero() ||
165 isa<Constant>(GEP->getOperand(2)))
174 for (unsigned i = 3, e = GEP->getNumOperands(); i != e; ++i) {
175 ConstantInt *Idx = dyn_cast<ConstantInt>(GEP->getOperand(i));
308 Value *Idx = GEP->getOperand(2);
311 // index down like the GEP would do implicitly. We don't have to do this for
312 // an inbounds GEP because the index can't be out of range.
313 if (!GEP->isInBounds()) {
314 Type *IntPtrTy = DL.getIntPtrType(GEP->getType());
415 /// Return a value that can be used to compare the *offset* implied by a GEP to
425 static Value *evaluateGEPOffsetExpression(User *GEP, InstCombiner &IC,
427 gep_type_iterator GTI = gep_type_begin(GEP);
431 // in terms of the scale of the variable index. For example, if the GEP
434 unsigned i, e = GEP->getNumOperands();
437 if (ConstantInt *CI = dyn_cast<ConstantInt>(GEP->getOperand(i))) {
458 Value *VariableIdx = GEP->getOperand(i);
465 ConstantInt *CI = dyn_cast<ConstantInt>(GEP->getOperand(i));
483 Type *IntPtrTy = DL.getIntPtrType(GEP->getOperand(0)->getType());
516 /// Returns true if we can rewrite Start as a GEP with pointer Base
562 if (auto *GEP = dyn_cast<GEPOperator>(V)) {
563 // We're limiting the GEP to having one index. This will preserve
566 if (GEP->getNumIndices() != 1 || !GEP->isInBounds() ||
567 GEP->getType() != Start->getType())
570 if (Explored.count(GEP->getOperand(0)) == 0)
571 WorkList.push_back(GEP->getOperand(0));
641 /// Returns a re-written value of Start as an indexed GEP using Base as a
684 if (auto *GEP = dyn_cast<GEPOperator>(Val)) {
685 Value *Index = NewInsts[GEP->getOperand(1)] ? NewInsts[GEP->getOperand(1)]
686 : GEP->getOperand(1);
687 setInsertionPoint(Builder, GEP);
691 NewInsts[GEP->getOperand(0)]->getType()->getScalarSizeInBits()) {
693 Index, NewInsts[GEP->getOperand(0)]->getType(),
694 GEP->getOperand(0)->getName() + ".sext");
697 auto *Op = NewInsts[GEP->getOperand(0)];
699 NewInsts[GEP] = Index;
701 NewInsts[GEP] = Builder.CreateNSWAdd(
702 Op, Index, GEP->getOperand(0)->getName() + ".add");
735 // a GEP or a GEP + ptrtoint.
744 Value *GEP = Builder.CreateInBoundsGEP(
749 Value *Cast = Builder.CreatePointerCast(GEP, Val->getType(),
751 GEP = Cast;
753 Val->replaceAllUsesWith(GEP);
760 /// the input Value as a constant indexed GEP. Returns a pair containing
769 if (GEPOperator *GEP = dyn_cast<GEPOperator>(V)) {
772 if (!GEP->isInBounds())
774 if (GEP->hasAllConstantIndices() && GEP->getNumIndices() == 1 &&
775 GEP->getType() == V->getType()) {
776 V = GEP->getOperand(0);
777 Constant *GEPIndex = static_cast<Constant *>(GEP->getOperand(1));
836 // GEP having PtrBase as the pointer base, and has returned in NewRHS the
842 /// Fold comparisons between a GEP instruction and something else. At this point
843 /// we know that the GEP is on the LHS of the comparison.
848 // GEP is inbounds, the final add of the base pointer can have signed overflow
968 // If the other GEP has all zero indices, recurse.
996 if (NumDifferences == 0) // SAME GEP?
1008 // Only lower this if the icmp is the only user of the GEP or if we expect
1837 if (auto *GEP = dyn_cast<GetElementPtrInst>(LI->getOperand(0)))
1838 if (auto *GV = dyn_cast<GlobalVariable>(GEP->getOperand(0)))
1842 if (Instruction *Res = foldCmpLoadFromIndexedGlobal(GEP, GV, Cmp, C2))
3177 // icmp pred GEP (P, int 0, int 0, int 0), null -> icmp pred P, null
3251 if (GetElementPtrInst *GEP =
3253 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(GEP->getOperand(0)))
3256 if (Instruction *Res = foldCmpLoadFromIndexedGlobal(GEP, GV, I))
5563 // If we can optimize a 'icmp GEP, P' or 'icmp P, GEP', do so now.
5564 if (GEPOperator *GEP = dyn_cast<GEPOperator>(Op0))
5565 if (Instruction *NI = foldGEPICmp(GEP, Op1, I.getPredicate(), I))
5567 if (GEPOperator *GEP = dyn_cast<GEPOperator>(Op1))
5568 if (Instruction *NI = foldGEPICmp(GEP, Op0,
6139 if (auto *GEP = dyn_cast<GetElementPtrInst>(LHSI->getOperand(0)))
6140 if (auto *GV = dyn_cast<GlobalVariable>(GEP->getOperand(0)))
6143 if (Instruction *Res = foldCmpLoadFromIndexedGlobal(GEP, GV, I))