Lines Matching refs:Inst

108   /// - Inst is used only once (no need to insert truncate).
109 /// - Inst has only one operand that will require a sext operation (we do
111 bool shouldGetThrough(const Instruction *Inst);
119 bool canGetThrough(const Instruction *Inst);
156 bool AArch64AddressTypePromotion::canGetThrough(const Instruction *Inst) {
157 if (isa<SExtInst>(Inst))
160 const BinaryOperator *BinOp = dyn_cast<BinaryOperator>(Inst);
166 if (isa<TruncInst>(Inst) && isa<SExtInst>(Inst->getOperand(0))) {
167 const Instruction *Opnd = cast<Instruction>(Inst->getOperand(0));
169 if (Inst->getType()->getIntegerBitWidth() >=
171 Inst->getOperand(0)->getType()->getIntegerBitWidth() <=
179 bool AArch64AddressTypePromotion::shouldGetThrough(const Instruction *Inst) {
184 if (isa<SExtInst>(Inst) &&
185 (Inst->getType() == ConsideredSExtType || Inst->hasOneUse()))
188 // If the Inst is used more that once, we may need to insert truncate
190 if (!Inst->hasOneUse())
195 if (isa<TruncInst>(Inst))
202 if (isa<BinaryOperator>(Inst) && isa<ConstantInt>(Inst->getOperand(1)))
208 static bool shouldSExtOperand(const Instruction *Inst, int OpIdx) {
209 return !(isa<SelectInst>(Inst) && OpIdx == 0);
270 while (auto *Inst = dyn_cast<Instruction>(SExt->getOperand(0))) {
271 DEBUG(dbgs() << "Try to get through:\n" << *Inst << '\n');
272 if (!canGetThrough(Inst) || !shouldGetThrough(Inst)) {
281 if (isa<SExtInst>(Inst) || isa<TruncInst>(Inst)) {
286 while (!Inst->use_empty()) {
287 Use &U = *Inst->use_begin();
292 ToRemove.insert(Inst);
293 SExt->setOperand(0, Inst->getOperand(0));
294 SExt->moveBefore(Inst);
300 // 2. Replace the uses of SExt by Inst.
304 Inst->mutateType(SExt->getType());
306 SExt->replaceAllUsesWith(Inst);
311 for (int OpIdx = 0, EndOpIdx = Inst->getNumOperands(); OpIdx != EndOpIdx;
313 DEBUG(dbgs() << "Operand:\n" << *(Inst->getOperand(OpIdx)) << '\n');
314 if (Inst->getOperand(OpIdx)->getType() == SExt->getType() ||
315 !shouldSExtOperand(Inst, OpIdx)) {
320 Value *Opnd = Inst->getOperand(OpIdx);
323 Inst->setOperand(OpIdx, ConstantInt::getSigned(SExt->getType(),
330 Inst->setOperand(OpIdx, UndefValue::get(SExt->getType()));
340 DEBUG(dbgs() << "Move before:\n" << *Inst << "\nSign extend\n");
342 SExtForOpnd->moveBefore(Inst);
343 Inst->setOperand(OpIdx, SExtForOpnd);
383 for (Instruction *Inst : Insts) {
384 if (ToRemove.count(Inst))
388 if (DT.dominates(Inst, Pt)) {
390 << *Inst << '\n');
391 Pt->replaceAllUsesWith(Inst);
393 Pt = Inst;
397 if (!DT.dominates(Pt, Inst))
402 DEBUG(dbgs() << "Replace all uses of:\n" << *Inst << "\nwith:\n"
404 Inst->replaceAllUsesWith(Pt);
405 ToRemove.insert(Inst);
410 CurPts.push_back(Inst);
439 const Instruction *Inst = dyn_cast<GetElementPtrInst>(U);
440 if (Inst && Inst->getNumOperands() > 2) {
441 DEBUG(dbgs() << "Interesting use in GetElementPtrInst\n" << *Inst
450 Instruction *Inst = SExt;
454 const BinaryOperator *BinOp = dyn_cast<BinaryOperator>(Inst);
457 Last = Inst->getOperand(OpdIdx);
458 Inst = dyn_cast<Instruction>(Last);
459 } while (Inst && canGetThrough(Inst) && shouldGetThrough(Inst));