Home | History | Annotate | Download | only in InstCombine

Lines Matching refs:AI

145 isOnlyCopiedFromConstantGlobal(AllocaInst *AI,
148 if (isOnlyCopiedFromConstantGlobal(AI, TheCopy, ToDelete))
153 Instruction *InstCombiner::visitAllocaInst(AllocaInst &AI) {
157 Type *IntPtrTy = TD->getIntPtrType(AI.getContext());
158 if (AI.getArraySize()->getType() != IntPtrTy) {
159 Value *V = Builder->CreateIntCast(AI.getArraySize(),
161 AI.setOperand(0, V);
162 return &AI;
167 if (AI.isArrayAllocation()) { // Check C != 1
168 if (const ConstantInt *C = dyn_cast<ConstantInt>(AI.getArraySize())) {
170 ArrayType::get(AI.getAllocatedType(), C->getZExtValue());
171 AllocaInst *New = Builder->CreateAlloca(NewTy, 0, AI.getName());
172 New->setAlignment(AI.getAlignment());
183 Value *NullIdx =Constant::getNullValue(Type::getInt32Ty(AI.getContext()));
193 return ReplaceInstUsesWith(AI, GEP);
194 } else if (isa<UndefValue>(AI.getArraySize())) {
195 return ReplaceInstUsesWith(AI, Constant::getNullValue(AI.getType()));
199 if (TD && AI.getAllocatedType()->isSized()) {
201 if (AI.getAlignment() == 0)
202 AI.setAlignment(TD->getPrefTypeAlignment(AI.getAllocatedType()));
207 if (TD->getTypeAllocSize(AI.getAllocatedType()) == 0) {
211 if (AI.isArrayAllocation()) {
212 AI.setOperand(0, ConstantInt::get(AI.getArraySize()->getType(), 1));
213 return &AI;
217 BasicBlock &EntryBlock = AI.getParent()->getParent()->getEntryBlock();
219 if (FirstInst != &AI) {
226 AI.moveBefore(FirstInst);
227 return &AI;
239 AI.getAlignment());
241 if (AI.getType() != EntryAI->getType())
242 return new BitCastInst(EntryAI, AI.getType());
243 return ReplaceInstUsesWith(AI, EntryAI);
248 if (AI.getAlignment()) {
256 if (MemTransferInst *Copy = isOnlyCopiedFromConstantGlobal(&AI, ToDelete)) {
258 AI.getAlignment(), TD);
259 if (AI.getAlignment() <= SourceAlign) {
260 DEBUG(dbgs() << "Found alloca equal to global: " << AI << '\n');
266 = ReplaceInstUsesWith(AI, ConstantExpr::getBitCast(TheSrc,
267 AI.getType()));
277 return visitAllocSite(AI);