Lines Matching refs:CI

30   if (ConstantInt *CI = dyn_cast<ConstantInt>(Val)) {
31 Offset = CI->getZExtValue();
81 Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI,
86 PointerType *PTy = cast<PointerType>(CI.getType());
149 // things that used it to use the new cast. This will also hack on CI, but it
157 return ReplaceInstUsesWith(CI, New);
238 const CastInst *CI, ///< The first cast instruction
244 Type *SrcTy = CI->getOperand(0)->getType(); // A from above
245 Type *MidTy = CI->getType(); // B from above
248 Instruction::CastOps firstOp = Instruction::CastOps(CI->getOpcode());
280 if (const CastInst *CI = dyn_cast<CastInst>(V))
281 if (isEliminableCastPair(CI, opc, Ty, DL))
294 Instruction *InstCombiner::commonCastTransforms(CastInst &CI) {
295 Value *Src = CI.getOperand(0);
301 isEliminableCastPair(CSrc, CI.getOpcode(), CI.getType(), DL)) {
303 // the second cast (CI). CSrc will then have a good chance of being dead.
304 return CastInst::Create(opc, CSrc->getOperand(0), CI.getType());
310 if (Instruction *NV = FoldOpIntoSelect(CI, SI))
318 !CI.getType()->isIntegerTy() ||
319 ShouldChangeType(CI.getType(), Src->getType()))
320 if (Instruction *NV = FoldOpIntoPhi(CI))
388 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->getOperand(1))) {
390 if (CI->getLimitedValue(BitWidth) < BitWidth)
398 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->getOperand(1))) {
403 CI->getLimitedValue(BitWidth) < BitWidth) {
439 Instruction *InstCombiner::visitTrunc(TruncInst &CI) {
440 if (Instruction *Result = commonCastTransforms(CI))
445 if (SimplifyDemandedInstructionBits(CI))
446 return &CI;
448 Value *Src = CI.getOperand(0);
449 Type *DestTy = CI.getType(), *SrcTy = Src->getType();
461 " to avoid cast: " << CI << '\n');
464 return ReplaceInstUsesWith(CI, Res);
488 return ReplaceInstUsesWith(CI, Constant::getNullValue(CI.getType()));
495 return CastInst::CreateIntegerCast(Shift, CI.getType(), false);
501 ShouldChangeType(Src->getType(), CI.getType()) &&
503 Value *NewTrunc = Builder->CreateTrunc(A, CI.getType(), A->getName()+".tr");
505 ConstantExpr::getTrunc(Cst, CI.getType()));
513 Instruction *InstCombiner::transformZExtICmp(ICmpInst *ICI, Instruction &CI,
531 if (In->getType() != CI.getType())
532 In = Builder->CreateIntCast(In, CI.getType(), false/*ZExt*/);
539 return ReplaceInstUsesWith(CI, In);
566 Constant *Res = ConstantInt::get(Type::getInt1Ty(CI.getContext()),
568 Res = ConstantExpr::getZExt(Res, CI.getType());
569 return ReplaceInstUsesWith(CI, Res);
586 if (CI.getType() == In->getType())
587 return ReplaceInstUsesWith(CI, In);
588 return CastInst::CreateIntegerCast(In, CI.getType(), false/*ZExt*/);
596 if (ICI->isEquality() && CI.getType() == ICI->getOperand(0)->getType()) {
597 if (IntegerType *ITy = dyn_cast<IntegerType>(CI.getType())) {
627 return ReplaceInstUsesWith(CI, Result);
760 Instruction *InstCombiner::visitZExt(ZExtInst &CI) {
763 if (CI.hasOneUse() && isa<TruncInst>(CI.user_back()))
767 if (Instruction *Result = commonCastTransforms(CI))
772 if (SimplifyDemandedInstructionBits(CI))
773 return &CI;
775 Value *Src = CI.getOperand(0);
776 Type *SrcTy = Src->getType(), *DestTy = CI.getType();
790 " to avoid zero extend: " << CI);
801 return ReplaceInstUsesWith(CI, Res);
820 unsigned DstSize = CI.getType()->getScalarSizeInBits();
829 return new ZExtInst(And, CI.getType());
838 Value *Trunc = Builder->CreateTrunc(A, CI.getType());
847 return transformZExtICmp(ICI, CI);
856 (transformZExtICmp(LHS, CI, false) ||
857 transformZExtICmp(RHS, CI, false))) {
858 Value *LCast = Builder->CreateZExt(LHS, CI.getType(), LHS->getName());
859 Value *RCast = Builder->CreateZExt(RHS, CI.getType(), RHS->getName());
869 X->getType() == CI.getType())
870 return BinaryOperator::CreateAnd(X, ConstantExpr::getZExt(C, CI.getType()));
876 X->getType() == CI.getType()) {
877 Constant *ZC = ConstantExpr::getZExt(C, CI.getType());
885 Value *New = Builder->CreateZExt(X, CI.getType());
886 return BinaryOperator::CreateXor(New, ConstantInt::get(CI.getType(), 1));
894 Instruction *InstCombiner::transformSExtICmp(ICmpInst *ICI, Instruction &CI) {
907 if (In->getType() != CI.getType())
908 In = Builder->CreateIntCast(In, CI.getType(), true/*SExt*/);
912 return ReplaceInstUsesWith(CI, In);
933 ConstantInt::getAllOnesValue(CI.getType()) :
934 ConstantInt::getNullValue(CI.getType());
935 return ReplaceInstUsesWith(CI, V);
966 if (CI.getType() == In->getType())
967 return ReplaceInstUsesWith(CI, In);
968 return CastInst::CreateIntegerCast(In, CI.getType(), true/*SExt*/);
1041 Instruction *InstCombiner::visitSExt(SExtInst &CI) {
1044 if (CI.hasOneUse() && isa<TruncInst>(CI.user_back()))
1047 if (Instruction *I = commonCastTransforms(CI))
1052 if (SimplifyDemandedInstructionBits(CI))
1053 return &CI;
1055 Value *Src = CI.getOperand(0);
1056 Type *SrcTy = Src->getType(), *DestTy = CI.getType();
1066 " to avoid sign extend: " << CI);
1076 return ReplaceInstUsesWith(CI, Res);
1098 return transformSExtICmp(ICI, CI);
1118 BA == CA && A->getType() == CI.getType()) {
1120 unsigned SrcDstSize = CI.getType()->getScalarSizeInBits();
1122 Constant *ShAmtV = ConstantInt::get(CI.getType(), ShAmt);
1123 A = Builder->CreateShl(A, ShAmtV, CI.getName());
1171 Instruction *InstCombiner::visitFPTrunc(FPTruncInst &CI) {
1172 if (Instruction *I = commonCastTransforms(CI))
1181 BinaryOperator *OpI = dyn_cast<BinaryOperator>(CI.getOperand(0));
1189 unsigned DstWidth = CI.getType()->getFPMantissaWidth();
1213 if (LHSOrig->getType() != CI.getType())
1214 LHSOrig = Builder->CreateFPExt(LHSOrig, CI.getType());
1215 if (RHSOrig->getType() != CI.getType())
1216 RHSOrig = Builder->CreateFPExt(RHSOrig, CI.getType());
1230 if (LHSOrig->getType() != CI.getType())
1231 LHSOrig = Builder->CreateFPExt(LHSOrig, CI.getType());
1232 if (RHSOrig->getType() != CI.getType())
1233 RHSOrig = Builder->CreateFPExt(RHSOrig, CI.getType());
1248 if (LHSOrig->getType() != CI.getType())
1249 LHSOrig = Builder->CreateFPExt(LHSOrig, CI.getType());
1250 if (RHSOrig->getType() != CI.getType())
1251 RHSOrig = Builder->CreateFPExt(RHSOrig, CI.getType());
1270 return CastInst::CreateFPCast(ExactResult, CI.getType());
1276 CI.getType());
1285 SelectInst *SI = dyn_cast<SelectInst>(CI.getOperand(0));
1290 CI.getType());
1292 CI.getType());
1296 IntrinsicInst *II = dyn_cast<IntrinsicInst>(CI.getOperand(0));
1303 CI.getType());
1304 Type *IntrinsicType[] = { CI.getType() };
1306 Intrinsic::getDeclaration(CI.getParent()->getParent()->getParent(),
1320 CallInst *Call = dyn_cast<CallInst>(CI.getOperand(0));
1328 CI.getType()->isFloatTy() &&
1333 Module *M = CI.getParent()->getParent()->getParent();
1354 Instruction *InstCombiner::visitFPExt(CastInst &CI) {
1355 return commonCastTransforms(CI);
1398 Instruction *InstCombiner::visitUIToFP(CastInst &CI) {
1399 return commonCastTransforms(CI);
1402 Instruction *InstCombiner::visitSIToFP(CastInst &CI) {
1403 return commonCastTransforms(CI);
1406 Instruction *InstCombiner::visitIntToPtr(IntToPtrInst &CI) {
1412 unsigned AS = CI.getAddressSpace();
1413 if (CI.getOperand(0)->getType()->getScalarSizeInBits() !=
1415 Type *Ty = DL->getIntPtrType(CI.getContext(), AS);
1416 if (CI.getType()->isVectorTy()) // Handle vectors of pointers.
1417 Ty = VectorType::get(Ty, CI.getType()->getVectorNumElements());
1419 Value *P = Builder->CreateZExtOrTrunc(CI.getOperand(0), Ty);
1420 return new IntToPtrInst(P, CI.getType());
1424 if (Instruction *I = commonCastTransforms(CI))
1431 Instruction *InstCombiner::commonPointerCastTransforms(CastInst &CI) {
1432 Value *Src = CI.getOperand(0);
1438 // If CI is an addrspacecast and GEP changes the poiner type, merging
1439 // GEP into CI would undo canonicalizing addrspacecast with different
1441 (!isa<AddrSpaceCastInst>(CI) ||
1447 CI.setOperand(0, GEP->getOperand(0));
1448 return &CI;
1452 return commonCastTransforms(CI);
1479 if (isa<BitCastInst>(CI))
1480 return new BitCastInst(NGEP, CI.getType());
1481 assert(isa<PtrToIntInst>(CI));
1482 return new PtrToIntInst(NGEP, CI.getType());
1487 return commonCastTransforms(CI);
1490 Instruction *InstCombiner::visitPtrToInt(PtrToIntInst &CI) {
1496 return commonPointerCastTransforms(CI);
1498 Type *Ty = CI.getType();
1499 unsigned AS = CI.getPointerAddressSpace();
1502 return commonPointerCastTransforms(CI);
1504 Type *PtrTy = DL->getIntPtrType(CI.getContext(), AS);
1508 Value *P = Builder->CreatePtrToInt(CI.getOperand(0), PtrTy);
1669 ConstantInt *CI = dyn_cast<ConstantInt>(I->getOperand(1));
1670 if (!CI) return false;
1671 Shift += CI->getZExtValue();
1695 static Value *OptimizeIntegerToVectorInsertions(BitCastInst &CI,
1700 VectorType *DestVecTy = cast<VectorType>(CI.getType());
1701 Value *IntInput = CI.getOperand(0);
1711 Value *Result = Constant::getNullValue(CI.getType());
1725 static Instruction *OptimizeIntToFloatBitCast(BitCastInst &CI,InstCombiner &IC){
1729 Value *Src = CI.getOperand(0);
1730 Type *DestTy = CI.getType();
1783 Instruction *InstCombiner::visitBitCast(BitCastInst &CI) {
1786 Value *Src = CI.getOperand(0);
1788 Type *DestTy = CI.getType();
1793 return ReplaceInstUsesWith(CI, Src);
1805 if (Instruction *V = PromoteCastOfAllocation(CI, *AI))
1812 Constant::getNullValue(Type::getInt32Ty(CI.getContext()));
1830 if (Instruction *I = OptimizeIntToFloatBitCast(CI, *this))
1837 Constant::getNullValue(Type::getInt32Ty(CI.getContext())));
1857 if (Value *V = OptimizeIntegerToVectorInsertions(CI, *this))
1858 return ReplaceInstUsesWith(CI, V);
1869 Constant::getNullValue(Type::getInt32Ty(CI.getContext())));
1876 dyn_cast<InsertElementInst>(CI.getOperand(0)))
1890 // If either of the operands is a cast from CI.getType(), then
1907 return commonPointerCastTransforms(CI);
1908 return commonCastTransforms(CI);
1911 Instruction *InstCombiner::visitAddrSpaceCast(AddrSpaceCastInst &CI) {
1915 Value *Src = CI.getOperand(0);
1917 PointerType *DestTy = cast<PointerType>(CI.getType()->getScalarType());
1922 if (VectorType *VT = dyn_cast<VectorType>(CI.getType())) {
1928 return new AddrSpaceCastInst(NewBitCast, CI.getType());
1931 return commonPointerCastTransforms(CI);