Home | History | Annotate | Download | only in Utils

Lines Matching refs:Div

383   assert(!Rem->getType()->isVectorTy() && "Div over vectors not supported");
386 "Div of bitwidth other than 32 or 64 not supported");
427 /// Generate code to divide two integers, replacing Div with the generated
433 /// @brief Replace Div with generated code.
434 bool llvm::expandDivision(BinaryOperator *Div) {
435 assert((Div->getOpcode() == Instruction::SDiv ||
436 Div->getOpcode() == Instruction::UDiv) &&
439 IRBuilder<> Builder(Div);
441 assert(!Div->getType()->isVectorTy() && "Div over vectors not supported");
442 assert((Div->getType()->getIntegerBitWidth() == 32 ||
443 Div->getType()->getIntegerBitWidth() == 64) &&
444 "Div of bitwidth other than 32 or 64 not supported");
447 if (Div->getOpcode() == Instruction::SDiv) {
448 // Lower the code to unsigned division, and reset Div to point to the udiv.
449 Value *Quotient = generateSignedDivisionCode(Div->getOperand(0),
450 Div->getOperand(1), Builder);
452 // Check whether this is the insert point while Div is still valid.
453 bool IsInsertPoint = Div->getIterator() == Builder.GetInsertPoint();
454 Div->replaceAllUsesWith(Quotient);
455 Div->dropAllReferences();
456 Div->eraseFromParent();
465 Div = BO;
469 Value *Quotient = generateUnsignedDivisionCode(Div->getOperand(0),
470 Div->getOperand(1),
472 Div->replaceAllUsesWith(Quotient);
473 Div->dropAllReferences();
474 Div->eraseFromParent();
492 assert(!RemTy->isVectorTy() && "Div over vectors not supported");
497 "Div of bitwidth greater than 32 not supported");
541 assert(!RemTy->isVectorTy() && "Div over vectors not supported");
545 assert(RemTyBitWidth <= 64 && "Div of bitwidth greater than 64 not supported");
583 /// @brief Replace Div with emulation code.
584 bool llvm::expandDivisionUpTo32Bits(BinaryOperator *Div) {
585 assert((Div->getOpcode() == Instruction::SDiv ||
586 Div->getOpcode() == Instruction::UDiv) &&
589 Type *DivTy = Div->getType();
590 assert(!DivTy->isVectorTy() && "Div over vectors not supported");
594 assert(DivTyBitWidth <= 32 && "Div of bitwidth greater than 32 not supported");
597 return expandDivision(Div);
601 IRBuilder<> Builder(Div);
609 if (Div->getOpcode() == Instruction::SDiv) {
610 ExtDividend = Builder.CreateSExt(Div->getOperand(0), Int32Ty);
611 ExtDivisor = Builder.CreateSExt(Div->getOperand(1), Int32Ty);
614 ExtDividend = Builder.CreateZExt(Div->getOperand(0), Int32Ty);
615 ExtDivisor = Builder.CreateZExt(Div->getOperand(1), Int32Ty);
620 Div->replaceAllUsesWith(Trunc);
621 Div->dropAllReferences();
622 Div->eraseFromParent();
631 /// @brief Replace Div with emulation code.
632 bool llvm::expandDivisionUpTo64Bits(BinaryOperator *Div) {
633 assert((Div->getOpcode() == Instruction::SDiv ||
634 Div->getOpcode() == Instruction::UDiv) &&
637 Type *DivTy = Div->getType();
638 assert(!DivTy->isVectorTy() && "Div over vectors not supported");
643 "Div of bitwidth greater than 64 not supported");
646 return expandDivision(Div);
650 IRBuilder<> Builder(Div);
658 if (Div->getOpcode() == Instruction::SDiv) {
659 ExtDividend = Builder.CreateSExt(Div->getOperand(0), Int64Ty);
660 ExtDivisor = Builder.CreateSExt(Div->getOperand(1), Int64Ty);
663 ExtDividend = Builder.CreateZExt(Div->getOperand(0), Int64Ty);
664 ExtDivisor = Builder.CreateZExt(Div->getOperand(1), Int64Ty);
669 Div->replaceAllUsesWith(Trunc);
670 Div->dropAllReferences();
671 Div->eraseFromParent();