Home | History | Annotate | Download | only in InstCombine

Lines Matching full:instruction

118   Instruction::BinaryOps Opcode = I.getOpcode();
119 if (Opcode != Instruction::Add &&
120 Opcode != Instruction::Sub) {
135 if (Opcode == Instruction::Add) {
181 Instruction::BinaryOps Opcode = I.getOpcode();
327 static bool LeftDistributesOverRight(Instruction::BinaryOps LOp,
328 Instruction::BinaryOps ROp) {
333 case Instruction::And:
338 case Instruction::Or:
339 case Instruction::Xor:
343 case Instruction::Mul:
348 case Instruction::Add:
349 case Instruction::Sub:
353 case Instruction::Or:
358 case Instruction::And:
366 static bool RightDistributesOverLeft(Instruction::BinaryOps LOp,
367 Instruction::BinaryOps ROp) {
368 if (Instruction::isCommutative(ROp))
377 case Instruction::And:
378 case Instruction::Or:
379 case Instruction::Xor:
383 case Instruction::Shl:
384 case Instruction::LShr:
385 case Instruction::AShr:
397 static Value *getIdentityValue(Instruction::BinaryOps OpCode, Value *V) {
401 if (OpCode == Instruction::Mul)
404 // TODO: We can handle other cases e.g. Instruction::And, Instruction::Or etc.
412 /// with TopLevelOpcode == Instruction::Add and Op = SHL(X, 2), transforms
413 /// SHL(X, 2) to MUL(X, 4) i.e. returns Instruction::Mul with LHS set to 'X' and
415 static Instruction::BinaryOps
416 getBinOpsForFactorization(Instruction::BinaryOps TopLevelOpcode,
419 return Instruction::BinaryOpsEnd;
428 case Instruction::Add:
429 case Instruction::Sub:
430 if (Op->getOpcode() == Instruction::Shl) {
434 return Instruction::Mul;
447 Instruction::BinaryOps InnerOpcode, Value *A,
457 Instruction::BinaryOps TopLevelOpcode = I.getOpcode();
460 bool InnerCommutative = Instruction::isCommutative(InnerOpcode);
464 // Does the instruction have the form "(A op' B) op (A op' D)" or, in the
483 // Does the instruction have the form "(A op' B) op (C op' B)" or, in the
543 // The instruction has the form "(A op' B) op (C op' D)". Try to factorize
550 // The instruction has the form "(A op' B) op (C)". Try to factorize common
556 // The instruction has the form "(B) op (C op' D)". Try to factorize common
564 // The instruction has the form "(A op' B) op C". See if expanding it out
567 Instruction::BinaryOps InnerOpcode = Op0->getOpcode(); // op'
576 (Instruction::isCommutative(InnerOpcode) && L == B && R == A))
581 // Otherwise, create a new instruction.
589 // The instruction has the form "A op (B op' C)". See if expanding it out
592 Instruction::BinaryOps InnerOpcode = Op1->getOpcode(); // op'
601 (Instruction::isCommutative(InnerOpcode) && L == C && R == B))
606 // Otherwise, create a new instruction.
616 // dyn_castNegVal - Given a 'sub' instruction, return the RHS of the instruction
634 // dyn_castFNegVal - Given a 'fsub' instruction, return the RHS of the
635 // instruction if the LHS is a constant negative zero (which is the 'negate'
653 static Value *FoldOperationIntoSelectOperand(Instruction &I, Value *SO,
676 Instruction *FPInst = dyn_cast<Instruction>(RI);
687 llvm_unreachable("Unknown binary instruction type!");
690 // FoldOpIntoSelect - Given an instruction with a select as one operand and a
694 Instruction *InstCombiner::FoldOpIntoSelect(Instruction &Op, SelectInst *SI) {
727 /// FoldOpIntoPhi - Given a binary operator, cast instruction, or select which
728 /// has a PHI node as operand #0, see if we can fold the instruction into the
731 Instruction *InstCombiner::FoldOpIntoPhi(Instruction &I) {
741 // Walk the use list for the instruction, comparing them to I.
743 Instruction *UI = cast<Instruction>(U);
773 // instruction, but insert another equivalent one, leading to infinite
860 Instruction *User = cast<Instruction>(*UI++);
981 std::pair<Instruction*, unsigned> Parent;
1007 if (BO->getOpcode() == Instruction::Mul) {
1045 if (logScale > 0 && BO->getOpcode() == Instruction::Shl &&
1078 if (Cast->getOpcode() == Instruction::SExt) {
1100 if (Cast->getOpcode() == Instruction::Trunc) {
1153 Instruction *Ancestor = Parent.first;
1165 } else if (Ancestor->getOpcode() == Instruction::Trunc) {
1171 assert((Ancestor->getOpcode() != Instruction::SExt || NoSignedWrap) &&
1287 Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
1407 Instruction *InsertPt = Builder->GetInsertPoint();
1427 // Combine Indices - If the source pointer to this getelementptr instruction
1428 // is a getelementptr instruction, combine the indices of the two
1429 // getelementptr instructions into a single instruction.
1533 return CastInst::Create(Instruction::IntToPtr, NewSub, GEP.getType());
1749 // If this GEP instruction doesn't move the pointer, just replace the GEP
1756 if (Instruction *I = visitBitCast(*BCI)) {
1796 isAllocSiteRemovable(Instruction *AI, SmallVectorImpl<WeakVH> &Users,
1798 SmallVector<Instruction*, 4> Worklist;
1802 Instruction *PI = Worklist.pop_back_val();
1804 Instruction *I = cast<Instruction>(U);
1810 case Instruction::BitCast:
1811 case Instruction::GetElementPtr:
1816 case Instruction::ICmp: {
1825 case Instruction::Call:
1858 case Instruction::Store: {
1872 Instruction *InstCombiner::visitAllocSite(Instruction &MI) {
1879 Instruction *I = cast_or_null<Instruction>(&*Users[i]);
1925 static Instruction *
1968 Instruction *InstCombiner::visitFree(CallInst &FI) {
1979 // If we have 'free null' delete the instruction. This can happen in stl code
1991 if (Instruction *I = tryToMoveFreeBeforeNullTest(FI))
1997 Instruction *InstCombiner::visitReturnInst(ReturnInst &RI) {
2017 Instruction *InstCombiner::visitBranchInst(BranchInst &BI) {
2074 Instruction *InstCombiner::visitSwitchInst(SwitchInst &SI) {
2110 if (Instruction *I = dyn_cast<Instruction>(Cond)) {
2111 if (I->getOpcode() == Instruction::Add)
2137 Instruction *InstCombiner::visitExtractValueInst(ExtractValueInst &EV) {
2155 // We're extracting from an insertvalue instruction, compare the indices
2212 // and replace it with a traditional binary instruction.
2318 Instruction *InstCombiner::visitLandingPadInst(LandingPadInst &LI) {
2327 SmallVector<Constant *, 16> NewClauses; // - Clauses for the new instruction;
2328 bool CleanupFlag = LI.isCleanup(); // - The new instruction is a cleanup.
2450 assert(MakeNewInstruction && "New filter but not a new instruction!");
2471 // new landingpad instruction if it does.
2585 // If we changed any of the clauses, replace the old landingpad instruction
2613 /// TryToSinkInstruction - Try to move the specified instruction from its
2615 /// safe to move the instruction past all of the instructions between it and the
2617 static bool TryToSinkInstruction(Instruction *I, BasicBlock *DestBlock) {
2647 Instruction *I = Worklist.RemoveOne();
2650 // Check to see if we can DCE the instruction.
2659 // Instruction isn't dead, see if we can constant propagate it.
2673 // See if we can trivially sink this instruction to a successor basic block.
2676 Instruction *UserInst = cast<Instruction>(*I->user_begin());
2698 // Okay, the CFG is simple enough, try to sink this instruction.
2701 // We'll add uses of the sunk instruction below, but since sinking
2705 if (Instruction *OpI = dyn_cast<Instruction>(U.get()))
2712 // Now that we have an instruction, try combining it to simplify it.
2722 if (Instruction *Result = visit(*I)) {
2724 // Should we replace the old instruction with a new one?
2731 // Everything uses the new instruction now.
2734 // Move the name to the new instruction first.
2737 // Push the new instruction and any users onto the worklist.
2741 // Insert the new instruction into the basic block...
2759 // If the instruction was modified, it's possible that it is now dead.
2793 SmallVector<Instruction*, 128> InstrsForInstCombineWorklist;
2804 Instruction *Inst = BBI++;
2806 // DCE instruction if trivially dead.
2814 // ConstantProp instruction if trivially constant.
2915 Instruction *EndInst = BB->getTerminator(); // Last not to be deleted.
2917 // Delete the next to last instruction.
2919 Instruction *Inst = --I;