Home | History | Annotate | Download | only in InstCombine

Lines Matching full:instruction

46       if (I->getOpcode() == Instruction::Shl) {
53 if (I->getOpcode() == Instruction::Mul) {
60 if (I->getOpcode() == Instruction::Add) {
79 /// PromoteCastOfAllocation - If we find a cast of an allocation instruction,
81 Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI,
149 // New is the allocation instruction, pointer typed. AI is the original
150 // allocation instruction, also pointer typed. Thus, cast to use is BitCast.
170 // Otherwise, it must be an instruction.
171 Instruction *I = cast<Instruction>(V);
172 Instruction *Res = nullptr;
175 case Instruction::Add:
176 case Instruction::Sub:
177 case Instruction::Mul:
178 case Instruction::And:
179 case Instruction::Or:
180 case Instruction::Xor:
181 case Instruction::AShr:
182 case Instruction::LShr:
183 case Instruction::Shl:
184 case Instruction::UDiv:
185 case Instruction::URem: {
188 Res = BinaryOperator::Create((Instruction::BinaryOps)Opc, LHS, RHS);
191 case Instruction::Trunc:
192 case Instruction::ZExt:
193 case Instruction::SExt:
203 Opc == Instruction::SExt);
205 case Instruction::Select: {
211 case Instruction::PHI: {
234 static Instruction::CastOps
235 isEliminableCastPair(const CastInst *CI, ///< First cast instruction
243 Instruction::CastOps firstOp = Instruction::CastOps(CI->getOpcode());
244 Instruction::CastOps secondOp = Instruction::CastOps(opcode);
257 if ((Res == Instruction::IntToPtr && SrcTy != DstIntPtrTy) ||
258 (Res == Instruction::PtrToInt && DstTy != SrcIntPtrTy))
261 return Instruction::CastOps(Res);
268 bool InstCombiner::ShouldOptimizeCast(Instruction::CastOps opc, const Value *V,
281 if (opc == Instruction::SExt && isa<CmpInst>(V) && Ty->isVectorTy())
289 Instruction *InstCombiner::commonCastTransforms(CastInst &CI) {
295 if (Instruction::CastOps opc =
305 if (Instruction *NV = FoldOpIntoSelect(CI, SI))
314 if (Instruction *NV = FoldOpIntoPhi(CI))
326 /// can be computed by computing V in the smaller type. If V is an instruction,
333 Instruction *CxtI) {
338 Instruction *I = dyn_cast<Instruction>(V);
350 // require duplicating the instruction in general, which isn't profitable.
355 case Instruction::Add:
356 case Instruction::Sub:
357 case Instruction::Mul:
358 case Instruction::And:
359 case Instruction::Or:
360 case Instruction::Xor:
365 case Instruction::UDiv:
366 case Instruction::URem: {
380 case Instruction::Shl:
389 case Instruction::LShr:
403 case Instruction::Trunc:
406 case Instruction::ZExt:
407 case Instruction::SExt:
411 case Instruction::Select: {
416 case Instruction::PHI: {
434 Instruction *InstCombiner::visitTrunc(TruncInst &CI) {
435 if (Instruction *Result = commonCastTransforms(CI))
508 Instruction *InstCombiner::transformZExtICmp(ICmpInst *ICI, Instruction &CI,
650 InstCombiner &IC, Instruction *CxtI) {
655 Instruction *I = dyn_cast<Instruction>(V);
664 // require duplicating the instruction in general, which isn't profitable.
669 case Instruction::ZExt: // zext(zext(x)) -> zext(x).
670 case Instruction::SExt: // zext(sext(x)) -> sext(x).
671 case Instruction::Trunc: // zext(trunc(x)) -> trunc(x) or zext(x)
673 case Instruction::And:
674 case Instruction::Or:
675 case Instruction::Xor:
676 case Instruction::Add:
677 case Instruction::Sub:
678 case Instruction::Mul:
689 (Opc == Instruction::And || Opc == Instruction::Or ||
690 Opc == Instruction::Xor)) {
703 case Instruction::Shl:
714 case Instruction::LShr:
727 case Instruction::Select:
736 case Instruction::PHI: {
757 Instruction *InstCombiner::visitZExt(ZExtInst &CI) {
764 if (Instruction *Result = commonCastTransforms(CI))
849 if (SrcI && SrcI->getOpcode() == Instruction::Or) {
859 return BinaryOperator::Create(Instruction::Or, LCast, RCast);
893 Instruction *InstCombiner::transformSExtICmp(ICmpInst *ICI, Instruction &CI) {
994 Instruction *I = dyn_cast<Instruction>(V);
1002 // require duplicating the instruction in general, which isn't profitable.
1006 case Instruction::SExt: // sext(sext(x)) -> sext(x)
1007 case Instruction::ZExt: // sext(zext(x)) -> zext(x)
1008 case Instruction::Trunc: // sext(trunc(x)) -> trunc(x) or sext(x)
1010 case Instruction::And:
1011 case Instruction::Or:
1012 case Instruction::Xor:
1013 case Instruction::Add:
1014 case Instruction::Sub:
1015 case Instruction::Mul:
1020 //case Instruction::Shl: TODO
1021 //case Instruction::LShr: TODO
1023 case Instruction::Select:
1027 case Instruction::PHI: {
1044 Instruction *InstCombiner::visitSExt(SExtInst &CI) {
1050 if (Instruction *I = commonCastTransforms(CI))
1154 /// LookThroughFPExtensions - If this is an fp extension instruction, look
1157 if (Instruction *I = dyn_cast<Instruction>(V))
1158 if (I->getOpcode() == Instruction::FPExt)
1183 Instruction *InstCombiner::visitFPTrunc(FPTruncInst &CI) {
1184 if (Instruction *I = commonCastTransforms(CI))
1204 case Instruction::FAdd:
1205 case Instruction::FSub:
1229 Instruction *RI =
1235 case Instruction::FMul:
1246 Instruction *RI =
1252 case Instruction::FDiv:
1264 Instruction *RI =
1270 case Instruction::FRem:
1283 if (Instruction *RI = dyn_cast<Instruction>(ExactResult))
1293 Instruction *RI = BinaryOperator::CreateFNeg(InnerTrunc);
1334 Instruction *InstCombiner::visitFPExt(CastInst &CI) {
1342 Instruction *InstCombiner::FoldItoFPtoI(Instruction &FI) {
1345 Instruction *OpI = cast<Instruction>(FI.getOperand(0));
1382 Instruction *InstCombiner::visitFPToUI(FPToUIInst &FI) {
1383 Instruction *OpI = dyn_cast<Instruction>(FI.getOperand(0));
1387 if (Instruction *I = FoldItoFPtoI(FI))
1393 Instruction *InstCombiner::visitFPToSI(FPToSIInst &FI) {
1394 Instruction *OpI = dyn_cast<Instruction>(FI.getOperand(0));
1398 if (Instruction *I = FoldItoFPtoI(FI))
1404 Instruction *InstCombiner::visitUIToFP(CastInst &CI) {
1408 Instruction *InstCombiner::visitSIToFP(CastInst &CI) {
1412 Instruction *InstCombiner::visitIntToPtr(IntToPtrInst &CI) {
1427 if (Instruction *I = commonCastTransforms(CI))
1434 Instruction *InstCombiner::commonPointerCastTransforms(CastInst &CI) {
1438 // If casting the result of a getelementptr instruction with no offset, turn
1458 Instruction *InstCombiner::visitPtrToInt(PtrToIntInst &CI) {
1482 static Instruction *OptimizeVectorResize(Value *InVal, VectorType *DestTy,
1614 Instruction *I = dyn_cast<Instruction>(V);
1618 case Instruction::BitCast:
1621 case Instruction::ZExt:
1628 case Instruction::Or:
1633 case Instruction::Shl: {
1647 /// OptimizeIntegerToVectorInsertions - If the input is an 'or' instruction, we
1689 static Instruction *OptimizeIntToFloatBitCast(BitCastInst &CI, InstCombiner &IC,
1745 Instruction *InstCombiner::visitBitCast(BitCastInst &CI) {
1763 // size, rewrite the allocation instruction to allocate the "right" type.
1767 if (Instruction *V = PromoteCastOfAllocation(CI, *AI))
1792 if (Instruction *I = OptimizeIntToFloatBitCast(CI, *this, DL))
1811 if (Instruction *I = OptimizeVectorResize(BCIn->getOperand(0),
1816 // If the input is an 'or' instruction, we may be doing shifts and ors to
1832 return CastInst::Create(Instruction::BitCast, Elem, DestTy);
1839 return CastInst::Create(Instruction::BitCast, IEI->getOperand(1),
1873 Instruction *InstCombiner::visitAddrSpaceCast(AddrSpaceCastInst &CI) {