Home | History | Annotate | Download | only in InstCombine

Lines Matching refs:CI

27   if (ConstantInt *CI = dyn_cast<ConstantInt>(Val)) {
28 Offset = CI->getZExtValue();
78 Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI,
83 PointerType *PTy = cast<PointerType>(CI.getType());
139 // things that used it to use the new cast. This will also hack on CI, but it
147 return ReplaceInstUsesWith(CI, New);
231 const CastInst *CI, ///< The first cast instruction
237 Type *SrcTy = CI->getOperand(0)->getType(); // A from above
238 Type *MidTy = CI->getType(); // B from above
241 Instruction::CastOps firstOp = Instruction::CastOps(CI->getOpcode());
246 TD ? TD->getIntPtrType(CI->getContext()) : 0);
251 (!TD || SrcTy != TD->getIntPtrType(CI->getContext()))) ||
253 (!TD || DstTy != TD->getIntPtrType(CI->getContext()))))
270 if (const CastInst *CI = dyn_cast<CastInst>(V))
271 if (isEliminableCastPair(CI, opc, Ty, TD))
284 Instruction *InstCombiner::commonCastTransforms(CastInst &CI) {
285 Value *Src = CI.getOperand(0);
291 isEliminableCastPair(CSrc, CI.getOpcode(), CI.getType(), TD)) {
293 // the second cast (CI). CSrc will then have a good chance of being dead.
294 return CastInst::Create(opc, CSrc->getOperand(0), CI.getType());
300 if (Instruction *NV = FoldOpIntoSelect(CI, SI))
308 !CI.getType()->isIntegerTy() ||
309 ShouldChangeType(CI.getType(), Src->getType()))
310 if (Instruction *NV = FoldOpIntoPhi(CI))
378 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->getOperand(1))) {
380 if (CI->getLimitedValue(BitWidth) < BitWidth)
388 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->getOperand(1))) {
393 CI->getLimitedValue(BitWidth) < BitWidth) {
429 Instruction *InstCombiner::visitTrunc(TruncInst &CI) {
430 if (Instruction *Result = commonCastTransforms(CI))
435 if (SimplifyDemandedInstructionBits(CI))
436 return &CI;
438 Value *Src = CI.getOperand(0);
439 Type *DestTy = CI.getType(), *SrcTy = Src->getType();
451 " to avoid cast: " << CI << '\n');
454 return ReplaceInstUsesWith(CI, Res);
478 return ReplaceInstUsesWith(CI, Constant::getNullValue(CI.getType()));
485 return CastInst::CreateIntegerCast(Shift, CI.getType(), false);
491 ShouldChangeType(Src->getType(), CI.getType()) &&
493 Value *NewTrunc = Builder->CreateTrunc(A, CI.getType(), A->getName()+".tr");
495 ConstantExpr::getTrunc(Cst, CI.getType()));
503 Instruction *InstCombiner::transformZExtICmp(ICmpInst *ICI, Instruction &CI,
521 if (In->getType() != CI.getType())
522 In = Builder->CreateIntCast(In, CI.getType(), false/*ZExt*/);
529 return ReplaceInstUsesWith(CI, In);
559 Constant *Res = ConstantInt::get(Type::getInt1Ty(CI.getContext()),
561 Res = ConstantExpr::getZExt(Res, CI.getType());
562 return ReplaceInstUsesWith(CI, Res);
579 if (CI.getType() == In->getType())
580 return ReplaceInstUsesWith(CI, In);
581 return CastInst::CreateIntegerCast(In, CI.getType(), false/*ZExt*/);
589 if (ICI->isEquality() && CI.getType() == ICI->getOperand(0)->getType()) {
590 if (IntegerType *ITy = dyn_cast<IntegerType>(CI.getType())) {
621 return ReplaceInstUsesWith(CI, Result);
746 Instruction *InstCombiner::visitZExt(ZExtInst &CI) {
749 if (CI.hasOneUse() && isa<TruncInst>(CI.use_back()))
753 if (Instruction *Result = commonCastTransforms(CI))
758 if (SimplifyDemandedInstructionBits(CI))
759 return &CI;
761 Value *Src = CI.getOperand(0);
762 Type *SrcTy = Src->getType(), *DestTy = CI.getType();
776 " to avoid zero extend: " << CI);
787 return ReplaceInstUsesWith(CI, Res);
806 unsigned DstSize = CI.getType()->getScalarSizeInBits();
815 return new ZExtInst(And, CI.getType());
824 Value *Trunc = Builder->CreateTrunc(A, CI.getType());
833 return transformZExtICmp(ICI, CI);
842 (transformZExtICmp(LHS, CI, false) ||
843 transformZExtICmp(RHS, CI, false))) {
844 Value *LCast = Builder->CreateZExt(LHS, CI.getType(), LHS->getName());
845 Value *RCast = Builder->CreateZExt(RHS, CI.getType(), RHS->getName());
855 if (TI0->getType() == CI.getType())
858 ConstantExpr::getZExt(C, CI.getType()));
869 if (TI0->getType() == CI.getType()) {
870 Constant *ZC = ConstantExpr::getZExt(C, CI.getType());
881 Value *New = Builder->CreateZExt(X, CI.getType());
882 return BinaryOperator::CreateXor(New, ConstantInt::get(CI.getType(), 1));
890 Instruction *InstCombiner::transformSExtICmp(ICmpInst *ICI, Instruction &CI) {
903 if (In->getType() != CI.getType())
904 In = Builder->CreateIntCast(In, CI.getType(), true/*SExt*/);
908 return ReplaceInstUsesWith(CI, In);
928 ConstantInt::getAllOnesValue(CI.getType()) :
929 ConstantInt::getNullValue(CI.getType());
930 return ReplaceInstUsesWith(CI, V);
961 if (CI.getType() == In->getType())
962 return ReplaceInstUsesWith(CI, In);
963 return CastInst::CreateIntegerCast(In, CI.getType(), true/*SExt*/);
969 if (VectorType *VTy = dyn_cast<VectorType>(CI.getType())) {
971 Op0->getType() == CI.getType()) {
977 return ReplaceInstUsesWith(CI, In);
1052 Instruction *InstCombiner::visitSExt(SExtInst &CI) {
1055 if (CI.hasOneUse() && isa<TruncInst>(CI.use_back()))
1058 if (Instruction *I = commonCastTransforms(CI))
1063 if (SimplifyDemandedInstructionBits(CI))
1064 return &CI;
1066 Value *Src = CI.getOperand(0);
1067 Type *SrcTy = Src->getType(), *DestTy = CI.getType();
1077 " to avoid sign extend: " << CI);
1087 return ReplaceInstUsesWith(CI, Res);
1109 return transformSExtICmp(ICI, CI);
1129 BA == CA && A->getType() == CI.getType()) {
1131 unsigned SrcDstSize = CI.getType()->getScalarSizeInBits();
1133 Constant *ShAmtV = ConstantInt::get(CI.getType(), ShAmt);
1134 A = Builder->CreateShl(A, ShAmtV, CI.getName());
1179 Instruction *InstCombiner::visitFPTrunc(FPTruncInst &CI) {
1180 if (Instruction *I = commonCastTransforms(CI))
1187 BinaryOperator *OpI = dyn_cast<BinaryOperator>(CI.getOperand(0));
1201 unsigned DstSize = CI
1206 LHSTrunc = Builder->CreateFPExt(LHSTrunc, CI.getType());
1207 RHSTrunc = Builder->CreateFPExt(RHSTrunc, CI.getType());
1217 CallInst *Call = dyn_cast<CallInst>(CI.getOperand(0));
1224 CI.getType()->isFloatTy() &&
1229 Module *M = CI.getParent()->getParent()->getParent();
1250 Instruction *InstCombiner::visitFPExt(CastInst &CI) {
1251 return commonCastTransforms(CI);
1294 Instruction *InstCombiner::visitUIToFP(CastInst &CI) {
1295 return commonCastTransforms(CI);
1298 Instruction *InstCombiner::visitSIToFP(CastInst &CI) {
1299 return commonCastTransforms(CI);
1302 Instruction *InstCombiner::visitIntToPtr(IntToPtrInst &CI) {
1307 if (CI.getOperand(0)->getType()->getScalarSizeInBits() >
1309 Value *P = Builder->CreateTrunc(CI.getOperand(0),
1310 TD->getIntPtrType(CI.getContext()));
1311 return new IntToPtrInst(P, CI.getType());
1313 if (CI.getOperand(0)->getType()->getScalarSizeInBits() <
1315 Value *P = Builder->CreateZExt(CI.getOperand(0),
1316 TD->getIntPtrType(CI.getContext()));
1317 return new IntToPtrInst(P, CI.getType());
1321 if (Instruction *I = commonCastTransforms(CI))
1328 Instruction *InstCombiner::commonPointerCastTransforms(CastInst &CI) {
1329 Value *Src = CI.getOperand(0);
1339 CI.setOperand(0, GEP->getOperand(0));
1340 return &CI;
1367 if (isa<BitCastInst>(CI))
1368 return new BitCastInst(NGEP, CI.getType());
1369 assert(isa<PtrToIntInst>(CI));
1370 return new PtrToIntInst(NGEP, CI.getType());
1375 return commonCastTransforms(CI);
1378 Instruction *InstCombiner::visitPtrToInt(PtrToIntInst &CI) {
1383 if (CI.getType()->getScalarSizeInBits() < TD->getPointerSizeInBits()) {
1384 Value *P = Builder->CreatePtrToInt(CI.getOperand(0),
1385 TD->getIntPtrType(CI.getContext()));
1386 return new TruncInst(P, CI.getType());
1388 if (CI.getType()->getScalarSizeInBits() > TD->getPointerSizeInBits()) {
1389 Value *P = Builder->CreatePtrToInt(CI.getOperand(0),
1390 TD->getIntPtrType(CI.getContext()));
1391 return new ZExtInst(P, CI.getType());
1395 return commonPointerCastTransforms(CI);
1544 ConstantInt *CI = dyn_cast<ConstantInt>(I->getOperand(1));
1545 if (CI == 0) return false;
1546 if (!isMultipleOfTypeSize(CI->getZExtValue(), VecEltTy)) return false;
1547 unsigned IndexShift = getTypeSizeIndex(CI->getZExtValue(), VecEltTy);
1571 static Value *OptimizeIntegerToVectorInsertions(BitCastInst &CI,
1573 VectorType *DestVecTy = cast<VectorType>(CI.getType());
1574 Value *IntInput = CI.getOperand(0);
1584 Value *Result = Constant::getNullValue(CI.getType());
1598 static Instruction *OptimizeIntToFloatBitCast(BitCastInst &CI,InstCombiner &IC){
1599 Value *Src = CI.getOperand(0);
1600 Type *DestTy = CI.getType();
1648 Instruction *InstCombiner::visitBitCast(BitCastInst &CI) {
1651 Value *Src = CI.getOperand(0);
1653 Type *DestTy = CI.getType();
1658 return ReplaceInstUsesWith(CI, Src);
1675 if (Instruction *V = PromoteCastOfAllocation(CI, *AI))
1682 Constant::getNullValue(Type::getInt32Ty(CI.getContext()));
1700 if (Instruction *I = OptimizeIntToFloatBitCast(CI, *this))
1707 Constant::getNullValue(Type::getInt32Ty(CI.getContext())));
1727 if (Value *V = OptimizeIntegerToVectorInsertions(CI, *this))
1728 return ReplaceInstUsesWith(CI, V);
1736 Constant::getNullValue(Type::getInt32Ty(CI.getContext())));
1750 // If either of the operands is a cast from CI.getType(), then
1767 return commonPointerCastTransforms(CI);
1768 return commonCastTransforms(CI);