Lines Matching defs:Div

361   assert(!Rem->getType()->isVectorTy() && "Div over vectors not supported");
400 /// Generate code to divide two integers, replacing Div with the generated
405 /// Replace Div with generated code.
406 bool llvm::expandDivision(BinaryOperator *Div) {
407 assert((Div->getOpcode() == Instruction::SDiv ||
408 Div->getOpcode() == Instruction::UDiv) &&
411 IRBuilder<> Builder(Div);
413 assert(!Div->getType()->isVectorTy() && "Div over vectors not supported");
416 if (Div->getOpcode() == Instruction::SDiv) {
417 // Lower the code to unsigned division, and reset Div to point to the udiv.
418 Value *Quotient = generateSignedDivisionCode(Div->getOperand(0),
419 Div->getOperand(1), Builder);
421 // Check whether this is the insert point while Div is still valid.
422 bool IsInsertPoint = Div->getIterator() == Builder.GetInsertPoint();
423 Div->replaceAllUsesWith(Quotient);
424 Div->dropAllReferences();
425 Div->eraseFromParent();
434 Div = BO;
438 Value *Quotient = generateUnsignedDivisionCode(Div->getOperand(0),
439 Div->getOperand(1),
441 Div->replaceAllUsesWith(Quotient);
442 Div->dropAllReferences();
443 Div->eraseFromParent();
461 assert(!RemTy->isVectorTy() && "Div over vectors not supported");
466 "Div of bitwidth greater than 32 not supported");
510 assert(!RemTy->isVectorTy() && "Div over vectors not supported");
550 /// Replace Div with emulation code.
551 bool llvm::expandDivisionUpTo32Bits(BinaryOperator *Div) {
552 assert((Div->getOpcode() == Instruction::SDiv ||
553 Div->getOpcode() == Instruction::UDiv) &&
556 Type *DivTy = Div->getType();
557 assert(!DivTy->isVectorTy() && "Div over vectors not supported");
561 assert(DivTyBitWidth <= 32 && "Div of bitwidth greater than 32 not supported");
564 return expandDivision(Div);
568 IRBuilder<> Builder(Div);
576 if (Div->getOpcode() == Instruction::SDiv) {
577 ExtDividend = Builder.CreateSExt(Div->getOperand(0), Int32Ty);
578 ExtDivisor = Builder.CreateSExt(Div->getOperand(1), Int32Ty);
581 ExtDividend = Builder.CreateZExt(Div->getOperand(0), Int32Ty);
582 ExtDivisor = Builder.CreateZExt(Div->getOperand(1), Int32Ty);
587 Div->replaceAllUsesWith(Trunc);
588 Div->dropAllReferences();
589 Div->eraseFromParent();
598 /// Replace Div with emulation code.
599 bool llvm::expandDivisionUpTo64Bits(BinaryOperator *Div) {
600 assert((Div->getOpcode() == Instruction::SDiv ||
601 Div->getOpcode() == Instruction::UDiv) &&
604 Type *DivTy = Div->getType();
605 assert(!DivTy->isVectorTy() && "Div over vectors not supported");
610 return expandDivision(Div);
614 IRBuilder<> Builder(Div);
622 if (Div->getOpcode() == Instruction::SDiv) {
623 ExtDividend = Builder.CreateSExt(Div->getOperand(0), Int64Ty);
624 ExtDivisor = Builder.CreateSExt(Div->getOperand(1), Int64Ty);
627 ExtDividend = Builder.CreateZExt(Div->getOperand(0), Int64Ty);
628 ExtDivisor = Builder.CreateZExt(Div->getOperand(1), Int64Ty);
633 Div->replaceAllUsesWith(Trunc);
634 Div->dropAllReferences();
635 Div->eraseFromParent();