Home | History | Annotate | Download | only in Scalar

Lines Matching refs:Instruction

62 static void PrintOps(Instruction *I, const SmallVectorImpl<ValueEntry> &Ops) {
64 dbgs() << Instruction::getOpcodeName(I->getOpcode()) << " "
100 Value *OptimizeAdd(Instruction *I, SmallVectorImpl<ValueEntry> &Ops);
118 Instruction *Op = dyn_cast<Instruction>(V);
131 static bool isUnmovableInstruction(Instruction *I) {
132 if (I->getOpcode() == Instruction::PHI ||
133 I->getOpcode() == Instruction::Alloca ||
134 I->getOpcode() == Instruction::Load ||
135 I->getOpcode() == Instruction::Invoke ||
136 (I->getOpcode() == Instruction::Call &&
138 I->getOpcode() == Instruction::UDiv ||
139 I->getOpcode() == Instruction::SDiv ||
140 I->getOpcode() == Instruction::FDiv ||
141 I->getOpcode() == Instruction::URem ||
142 I->getOpcode() == Instruction::SRem ||
143 I->getOpcode() == Instruction::FRem)
171 Instruction *I = dyn_cast<Instruction>(V);
189 // If this is a not or neg instruction, do not count it for rank. This
201 /// isReassociableOp - Return true if V is an instruction of the specified
204 if ((V->hasOneUse() || V->use_empty()) && isa<Instruction>(V) &&
205 cast<Instruction>(V)->getOpcode() == Opcode)
212 static Instruction *LowerNegateToMultiply(Instruction *Neg,
216 Instruction *Res = BinaryOperator::CreateMul(Neg->getOperand(1), Cst, "",Neg);
238 // Move the RHS instruction to live immediately before I, avoiding breaking
283 if (I->getOpcode() == Instruction::Mul) {
285 LHS = LowerNegateToMultiply(cast<Instruction>(LHS), ValueRankMap);
289 RHS = LowerNegateToMultiply(cast<Instruction>(RHS), ValueRankMap);
397 // NegateValue - Insert instructions before the instruction pointed to by BI,
399 // version of the value is returned, and BI is left pointing at the instruction
402 static Value *NegateValue(Value *V, Instruction *BI) {
415 if (Instruction *I = dyn_cast<Instruction>(V))
416 if (I->getOpcode() == Instruction::Add && I->hasOneUse()) {
421 // We must move the add instruction here, because the neg instructions do
422 // not dominate the old add instruction in general. By moving it, we are
424 // instruction we are about to insert after them.
431 // Okay, we need to materialize a negated version of V with an instruction.
439 // non-instruction value) or right after the definition. These negates will
448 if (Instruction *InstInput = dyn_cast<Instruction>(V)) {
463 // Insert a 'neg' instruction that subtracts the value from zero to get the
470 static bool ShouldBreakUpSubtract(Instruction *Sub) {
477 if (isReassociableOp(Sub->getOperand(0), Instruction::Add) ||
478 isReassociableOp(Sub->getOperand(0), Instruction::Sub))
480 if (isReassociableOp(Sub->getOperand(1), Instruction::Add) ||
481 isReassociableOp(Sub->getOperand(1), Instruction::Sub))
484 (isReassociableOp(Sub->use_back(), Instruction::Add) ||
485 isReassociableOp(Sub->use_back(), Instruction::Sub)))
494 static Instruction *BreakUpSubtract(Instruction *Sub,
496 // Convert a subtract into an add and a neg instruction. This allows sub
499 // Calculate the negative value of Operand 1 of the sub instruction,
500 // and set it as the RHS of the add instruction we just made.
503 Instruction *New =
507 // Everyone now refers to the add instruction.
520 static Instruction *ConvertShiftToMul(Instruction *Shl,
524 if (isReassociableOp(Shl->getOperand(0), Instruction::Mul) ||
526 (isReassociableOp(Shl->use_back(), Instruction::Mul) ||
527 isReassociableOp(Shl->use_back(), Instruction::Add)))) {
531 Instruction *Mul =
562 static Value *EmitAddTreeOfValues(Instruction *I, SmallVectorImpl<Value*> &Ops){
575 BinaryOperator *BO = isReassociableOp(V, Instruction::Mul);
636 BO->getOpcode() != Instruction::Mul) {
659 /// instruction. This optimizes based on identities. If it can be reduced to
673 if (Opcode == Instruction::And) // ...&X&~X = 0
676 if (Opcode == Instruction::Or) // ...|X|~X = -1
685 if (Opcode == Instruction::And || Opcode == Instruction::Or) {
694 assert(Opcode == Instruction::Xor);
707 /// OptimizeAdd - Optimize a series of operands to an 'add' instruction. This
710 Value *Reassociate::OptimizeAdd(Instruction *I,
794 if (BOp == 0 || BOp->getOpcode() != Instruction::Mul || !BOp->use_empty())
831 // Create a new instruction that uses the MaxOccVal twice. If we don't do
835 Instruction *DummyInst = BinaryOperator::CreateAdd(MaxOccVal, MaxOccVal);
840 if (BOp == 0 || BOp->getOpcode() != Instruction::Mul || !BOp->use_empty())
911 case Instruction::And:
917 case Instruction::Mul:
926 case Instruction::Or:
930 case Instruction::Add:
931 case Instruction::Xor:
942 case Instruction::And:
943 case Instruction::Or:
944 case Instruction::Xor: {
952 case Instruction::Add: {
960 //case Instruction::Mul:
969 /// ReassociateInst - Inspect and reassociate the instruction at the
972 Instruction *BI = BBI++;
973 if (BI->getOpcode() == Instruction::Shl &&
975 if (Instruction *NI = ConvertShiftToMul(BI, ValueRankMap)) {
994 // If this is a subtract instruction which is not already in negate form,
996 if (BI->getOpcode() == Instruction::Sub) {
1000 // instruction it points to.
1007 if (isReassociableOp(BI->getOperand(1), Instruction::Mul) &&
1009 !isReassociableOp(BI->use_back(), Instruction::Mul))) {
1016 // If this instruction is a commutative binary operator, process it.
1025 // If this is an add tree that is used by a sub instruction, ignore it
1027 if (I->hasOneUse() && I->getOpcode() == Instruction::Add &&
1028 cast<Instruction>(I->use_back())->getOpcode() == Instruction::Sub)
1058 if (Instruction *VI = dyn_cast<Instruction>(V))
1069 if (I->getOpcode() == Instruction::Mul && I->hasOneUse() &&
1070 cast<Instruction>(I->use_back())->getOpcode() == Instruction::Add &&
1083 if (Instruction *OI = dyn_cast<Instruction>(Ops[0].Op))
1109 BasicBlock::iterator BBI = cast<Instruction>(V);