Home | History | Annotate | Download | only in InstCombine

Lines Matching full:instruction

44       if (I->getOpcode() == Instruction::Shl) {
51 if (I->getOpcode() == Instruction::Mul) {
58 if (I->getOpcode() == Instruction::Add) {
77 /// PromoteCastOfAllocation - If we find a cast of an allocation instruction,
79 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 = 0;
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: {
233 static Instruction::CastOps
235 const CastInst *CI, ///< The first cast instruction
236 unsigned opcode, ///< The opcode of the second cast instruction
237 Type *DstTy, ///< The target type for the second cast instruction
245 Instruction::CastOps firstOp = Instruction::CastOps(CI->getOpcode());
246 Instruction::CastOps secondOp = Instruction::CastOps(opcode);
259 if ((Res == Instruction::IntToPtr && SrcTy != DstIntPtrTy) ||
260 (Res == Instruction::PtrToInt && DstTy != SrcIntPtrTy))
263 return Instruction::CastOps(Res);
270 bool InstCombiner::ShouldOptimizeCast(Instruction::CastOps opc, const Value *V,
283 if (opc == Instruction::SExt && isa<CmpInst>(V) && Ty->isVectorTy())
291 Instruction *InstCombiner::commonCastTransforms(CastInst &CI) {
297 if (Instruction::CastOps opc =
307 if (Instruction *NV = FoldOpIntoSelect(CI, SI))
317 if (Instruction *NV = FoldOpIntoPhi(CI))
329 /// can be computed by computing V in the smaller type. If V is an instruction,
340 Instruction *I = dyn_cast<Instruction>(V);
352 // require duplicating the instruction in general, which isn't profitable.
357 case Instruction::Add:
358 case Instruction::Sub:
359 case Instruction::Mul:
360 case Instruction::And:
361 case Instruction::Or:
362 case Instruction::Xor:
367 case Instruction::UDiv:
368 case Instruction::URem: {
382 case Instruction::Shl:
391 case Instruction::LShr:
405 case Instruction::Trunc:
408 case Instruction::ZExt:
409 case Instruction::SExt:
413 case Instruction::Select: {
418 case Instruction::PHI: {
436 Instruction *InstCombiner::visitTrunc(TruncInst &CI) {
437 if (Instruction *Result = commonCastTransforms(CI))
510 Instruction *InstCombiner::transformZExtICmp(ICmpInst *ICI, Instruction &CI,
656 Instruction *I = dyn_cast<Instruction>(V);
665 // require duplicating the instruction in general, which isn't profitable.
670 case Instruction::ZExt: // zext(zext(x)) -> zext(x).
671 case Instruction::SExt: // zext(sext(x)) -> sext(x).
672 case Instruction::Trunc: // zext(trunc(x)) -> trunc(x) or zext(x)
674 case Instruction::And:
675 case Instruction::Or:
676 case Instruction::Xor:
677 case Instruction::Add:
678 case Instruction::Sub:
679 case Instruction::Mul:
690 (Opc == Instruction::And || Opc == Instruction::Or ||
691 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))
847 if (SrcI && SrcI->getOpcode() == Instruction::Or) {
857 return BinaryOperator::Create(Instruction::Or, LCast, RCast);
862 if (SrcI && SrcI->getOpcode() == Instruction::And && SrcI->hasOneUse())
873 if (SrcI && SrcI->getOpcode() == Instruction::Xor && SrcI->hasOneUse())
876 if (And->getOpcode() == Instruction::And && And->hasOneUse() &&
901 Instruction *InstCombiner::transformSExtICmp(ICmpInst *ICI, Instruction &CI) {
1009 Instruction *I = dyn_cast<Instruction>(V);
1017 // require duplicating the instruction in general, which isn't profitable.
1021 case Instruction::SExt: // sext(sext(x)) -> sext(x)
1022 case Instruction::ZExt: // sext(zext(x)) -> zext(x)
1023 case Instruction::Trunc: // sext(trunc(x)) -> trunc(x) or sext(x)
1025 case Instruction::And:
1026 case Instruction::Or:
1027 case Instruction::Xor:
1028 case Instruction::Add:
1029 case Instruction::Sub:
1030 case Instruction::Mul:
1035 //case Instruction::Shl: TODO
1036 //case Instruction::LShr: TODO
1038 case Instruction::Select:
1042 case Instruction::PHI: {
1059 Instruction *InstCombiner::visitSExt(SExtInst &CI) {
1065 if (Instruction *I = commonCastTransforms(CI))
1160 /// LookThroughFPExtensions - If this is an fp extension instruction, look
1163 if (Instruction *I = dyn_cast<Instruction>(V))
1164 if (I->getOpcode() == Instruction::FPExt)
1189 Instruction *InstCombiner::visitFPTrunc(FPTruncInst &CI) {
1190 if (Instruction *I = commonCastTransforms(CI))
1201 case Instruction
1202 case Instruction::FSub:
1203 case Instruction::FMul:
1204 case Instruction::FDiv:
1205 case Instruction::FRem:
1258 if (Arg && Arg->getOpcode() == Instruction::FPExt &&
1285 Instruction *InstCombiner::visitFPExt(CastInst &CI) {
1289 Instruction *InstCombiner::visitFPToUI(FPToUIInst &FI) {
1290 Instruction *OpI = dyn_cast<Instruction>(FI.getOperand(0));
1309 Instruction *InstCombiner::visitFPToSI(FPToSIInst &FI) {
1310 Instruction *OpI = dyn_cast<Instruction>(FI.getOperand(0));
1329 Instruction *InstCombiner::visitUIToFP(CastInst &CI) {
1333 Instruction *InstCombiner::visitSIToFP(CastInst &CI) {
1337 Instruction *InstCombiner::visitIntToPtr(IntToPtrInst &CI) {
1351 if (Instruction *I = commonCastTransforms(CI))
1358 Instruction *InstCombiner::commonPointerCastTransforms(CastInst &CI) {
1362 // If casting the result of a getelementptr instruction with no offset, turn
1405 Instruction *InstCombiner::visitPtrToInt(PtrToIntInst &CI) {
1426 static Instruction *OptimizeVectorResize(Value *InVal, VectorType *DestTy,
1547 Instruction *I = dyn_cast<Instruction>(V);
1551 case Instruction::BitCast:
1554 case Instruction::ZExt:
1561 case Instruction::Or:
1566 case Instruction::Shl: {
1581 /// OptimizeIntegerToVectorInsertions - If the input is an 'or' instruction, we
1622 static Instruction *OptimizeIntToFloatBitCast(BitCastInst &CI,InstCombiner &IC){
1680 Instruction *InstCombiner::visitBitCast(BitCastInst &CI) {
1703 // size, rewrite the allocation instruction to allocate the "right" type.
1707 if (Instruction *V = PromoteCastOfAllocation(CI, *AI))
1732 if (Instruction *I = OptimizeIntToFloatBitCast(CI, *this))
1751 if (Instruction *I = OptimizeVectorResize(BCIn->getOperand(0),
1756 // If the input is an 'or' instruction, we may be doing shifts and ors to
1772 return CastInst::Create(Instruction::BitCast, Elem, DestTy);
1779 return CastInst::Create(Instruction::BitCast, IEI->getOperand(1),