Newer
Older
case CmpInst::FCMP_OLT:
case CmpInst::FCMP_ULT:
NewPred = CmpInst::ICMP_ULT;
break;
case CmpInst::FCMP_OLE:
case CmpInst::FCMP_ULE:
NewPred = CmpInst::ICMP_ULE;
break;
default:
break;
if (NewPred == CmpInst::BAD_ICMP_PREDICATE) return;
// Insert new integer induction variable.
PHINode *NewPHI = PHINode::Create(Type::Int32Ty,
PH->getName()+".int", PH);
Devang Patel
committed
NewPHI->addIncoming(ConstantInt::get(Type::Int32Ty, newInitValue),
PH->getIncomingBlock(IncomingEdge));
Value *NewAdd = BinaryOperator::CreateAdd(NewPHI,
ConstantInt::get(Type::Int32Ty,
Devang Patel
committed
newIncrValue),
Incr->getName()+".int", Incr);
NewPHI->addIncoming(NewAdd, PH->getIncomingBlock(BackEdge));
ConstantInt *NewEV = ConstantInt::get(Type::Int32Ty, intEV);
Value *LHS = (EVIndex == 1 ? NewPHI->getIncomingValue(BackEdge) : NewEV);
Value *RHS = (EVIndex == 1 ? NewEV : NewPHI->getIncomingValue(BackEdge));
ICmpInst *NewEC = new ICmpInst(NewPred, LHS, RHS, EC->getNameStart(),
EC->getParent()->getTerminator());
// Delete old, floating point, exit comparision instruction.
EC->replaceAllUsesWith(NewEC);
DeadInsts.insert(EC);
// Delete old, floating point, increment instruction.
Incr->replaceAllUsesWith(UndefValue::get(Incr->getType()));
DeadInsts.insert(Incr);
// Replace floating induction variable. Give SIToFPInst preference over
// UIToFPInst because it is faster on platforms that are widely used.
if (useSIToFPInst(*InitValue, *EV, newInitValue, intEV)) {
SIToFPInst *Conv = new SIToFPInst(NewPHI, PH->getType(), "indvar.conv",
Devang Patel
committed
PH->getParent()->getFirstNonPHI());
PH->replaceAllUsesWith(Conv);
} else {
UIToFPInst *Conv = new UIToFPInst(NewPHI, PH->getType(), "indvar.conv",
Devang Patel
committed
PH->getParent()->getFirstNonPHI());
PH->replaceAllUsesWith(Conv);
}
DeadInsts.insert(PH);