Home | History | Annotate | Download | only in InstCombine

Lines Matching refs:Instruction

46       if (I->getOpcode() == Instruction::Shl) {
53 if (I->getOpcode() == Instruction::Mul) {
60 if (I->getOpcode() == Instruction::Add) {
79 /// If we find a cast of an allocation instruction, try to eliminate the cast by
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.
169 // Otherwise, it must be an instruction.
170 Instruction *I = cast<Instruction>(V);
171 Instruction *Res = nullptr;
174 case Instruction::Add:
175 case Instruction::Sub:
176 case Instruction::Mul:
177 case Instruction::And:
178 case Instruction::Or:
179 case Instruction::Xor:
180 case Instruction::AShr:
181 case Instruction::LShr:
182 case Instruction::Shl:
183 case Instruction::UDiv:
184 case Instruction::URem: {
187 Res = BinaryOperator::Create((Instruction::BinaryOps)Opc, LHS, RHS);
190 case Instruction::Trunc:
191 case Instruction::ZExt:
192 case Instruction::SExt:
202 Opc == Instruction::SExt);
204 case Instruction::Select: {
210 case Instruction::PHI: {
233 static Instruction::CastOps
234 isEliminableCastPair(const CastInst *CI, ///< First cast instruction
242 Instruction::CastOps firstOp = Instruction::CastOps(CI->getOpcode());
243 Instruction::CastOps secondOp = Instruction::CastOps(opcode);
256 if ((Res == Instruction::IntToPtr && SrcTy != DstIntPtrTy) ||
257 (Res == Instruction::PtrToInt && DstTy != SrcIntPtrTy))
260 return Instruction::CastOps(Res);
267 bool InstCombiner::ShouldOptimizeCast(Instruction::CastOps opc, const Value *V,
280 if (opc == Instruction::SExt && isa<CmpInst>(V) && Ty->isVectorTy())
288 Instruction *InstCombiner::commonCastTransforms(CastInst &CI) {
294 if (Instruction::CastOps opc =
304 if (Instruction *NV = FoldOpIntoSelect(CI, SI))
313 if (Instruction *NV = FoldOpIntoPhi(CI))
325 /// can be computed by computing V in the smaller type. If V is an instruction,
332 Instruction *CxtI) {
337 Instruction *I = dyn_cast<Instruction>(V);
349 // require duplicating the instruction in general, which isn't profitable.
354 case Instruction::Add:
355 case Instruction::Sub:
356 case Instruction::Mul:
357 case Instruction::And:
358 case Instruction::Or:
359 case Instruction::Xor:
364 case Instruction::UDiv:
365 case Instruction::URem: {
379 case Instruction::Shl:
388 case Instruction::LShr:
402 case Instruction::Trunc:
405 case Instruction::ZExt:
406 case Instruction::SExt:
410 case Instruction::Select: {
415 case Instruction::PHI: {
439 static Instruction *foldVecTruncToExtElt(TruncInst &Trunc, InstCombiner &IC,
477 Instruction *InstCombiner::visitTrunc(TruncInst &CI) {
478 if (Instruction *Result = commonCastTransforms(CI))
552 cast<Instruction>(Src)->getOperand(0)->hasOneUse()) {
575 if (Instruction *I = foldVecTruncToExtElt(CI, *this, DL))
583 Instruction *InstCombiner::transformZExtICmp(ICmpInst *ICI, Instruction &CI,
725 InstCombiner &IC, Instruction *CxtI) {
730 Instruction *I = dyn_cast<Instruction>(V);
739 // require duplicating the instruction in general, which isn't profitable.
744 case Instruction::ZExt: // zext(zext(x)) -> zext(x).
745 case Instruction::SExt: // zext(sext(x)) -> sext(x).
746 case Instruction::Trunc: // zext(trunc(x)) -> trunc(x) or zext(x)
748 case Instruction::And:
749 case Instruction::Or:
750 case Instruction::Xor:
751 case Instruction::Add:
752 case Instruction::Sub:
753 case Instruction::Mul:
764 (Opc == Instruction::And || Opc == Instruction::Or ||
765 Opc == Instruction::Xor)) {
778 case Instruction::Shl:
789 case Instruction::LShr:
802 case Instruction::Select:
811 case Instruction::PHI: {
832 Instruction *InstCombiner::visitZExt(ZExtInst &CI) {
839 if (Instruction *Result = commonCastTransforms(CI))
924 if (SrcI && SrcI->getOpcode() == Instruction::Or) {
934 return BinaryOperator::Create(Instruction::Or, LCast, RCast);
967 Instruction *InstCombiner::transformSExtICmp(ICmpInst *ICI, Instruction &CI) {
1067 Instruction *I = dyn_cast<Instruction>(V);
1075 // require duplicating the instruction in general, which isn't profitable.
1079 case Instruction::SExt: // sext(sext(x)) -> sext(x)
1080 case Instruction::ZExt: // sext(zext(x)) -> zext(x)
1081 case Instruction::Trunc: // sext(trunc(x)) -> trunc(x) or sext(x)
1083 case Instruction::And:
1084 case Instruction::Or:
1085 case Instruction::Xor:
1086 case Instruction::Add:
1087 case Instruction::Sub:
1088 case Instruction::Mul:
1093 //case Instruction::Shl: TODO
1094 //case Instruction::LShr: TODO
1096 case Instruction::Select:
1100 case Instruction::PHI: {
1117 Instruction *InstCombiner::visitSExt(SExtInst &CI) {
1123 if (Instruction *I = commonCastTransforms(CI))
1227 /// If this is a floating-point extension instruction, look
1230 if (Instruction *I = dyn_cast<Instruction>(V))
1231 if (I->getOpcode() == Instruction::FPExt)
1256 Instruction *InstCombiner::visitFPTrunc(FPTruncInst &CI) {
1257 if (Instruction *I = commonCastTransforms(CI))
1277 case Instruction::FAdd:
1278 case Instruction::FSub:
1302 Instruction *RI =
1308 case Instruction::FMul:
1319 Instruction *RI =
1325 case Instruction::FDiv:
1337 Instruction *RI =
1343 case Instruction::FRem:
1356 if (Instruction *RI = dyn_cast<Instruction>(ExactResult))
1366 Instruction *RI = BinaryOperator::CreateFNeg(InnerTrunc);
1415 Instruction *InstCombiner::visitFPExt(CastInst &CI) {
1423 Instruction *InstCombiner::FoldItoFPtoI(Instruction &FI) {
1426 Instruction *OpI = cast<Instruction>(FI.getOperand(0));
1463 Instruction *InstCombiner::visitFPToUI(FPToUIInst &FI) {
1464 Instruction *OpI = dyn_cast<Instruction>(FI.getOperand(0));
1468 if (Instruction *I = FoldItoFPtoI(FI))
1474 Instruction *InstCombiner::visitFPToSI(FPToSIInst &FI) {
1475 Instruction *OpI = dyn_cast<Instruction>(FI.getOperand(0));
1479 if (Instruction *I = FoldItoFPtoI(FI))
1485 Instruction *InstCombiner::visitUIToFP(CastInst &CI) {
1489 Instruction *InstCombiner::visitSIToFP(CastInst &CI) {
1493 Instruction *InstCombiner::visitIntToPtr(IntToPtrInst &CI) {
1508 if (Instruction *I = commonCastTransforms(CI))
1515 Instruction *InstCombiner::commonPointerCastTransforms(CastInst &CI) {
1519 // If casting the result of a getelementptr instruction with no offset, turn
1539 Instruction *InstCombiner::visitPtrToInt(PtrToIntInst &CI) {
1563 static Instruction *optimizeVectorResize(Value *InVal, VectorType *DestTy,
1695 Instruction *I = dyn_cast<Instruction>(V);
1699 case Instruction::BitCast:
1702 case Instruction::ZExt:
1709 case Instruction::Or:
1714 case Instruction::Shl: {
1728 /// If the input is an 'or' instruction, we may be doing shifts and ors to
1771 static Instruction *canonicalizeBitCastExtElt(BitCastInst &BitCast,
1792 Instruction *InstCombiner::visitBitCast(BitCastInst &CI) {
1810 // size, rewrite the allocation instruction to allocate the "right" type.
1814 if (Instruction *V = PromoteCastOfAllocation(CI, *AI))
1858 if (Instruction *I = optimizeVectorResize(BCIn->getOperand(0),
1863 // If the input is an 'or' instruction, we may be doing shifts and ors to
1879 return CastInst::Create(Instruction::BitCast, Elem, DestTy);
1886 return CastInst::Create(Instruction::BitCast, IEI->getOperand(1),
1915 if (Instruction *I = canonicalizeBitCastExtElt(CI, *this, DL))
1923 Instruction *InstCombiner::visitAddrSpaceCast(AddrSpaceCastInst &CI) {