• Home
  • Raw
  • Download

Lines Matching refs:CI

30   if (ConstantInt *CI = dyn_cast<ConstantInt>(Val)) {  in decomposeSimpleLinearExpr()  local
31 Offset = CI->getZExtValue(); in decomposeSimpleLinearExpr()
81 Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI, in PromoteCastOfAllocation() argument
83 PointerType *PTy = cast<PointerType>(CI.getType()); in PromoteCastOfAllocation()
154 return replaceInstUsesWith(CI, New); in PromoteCastOfAllocation()
234 isEliminableCastPair(const CastInst *CI, ///< First cast instruction in isEliminableCastPair() argument
238 Type *SrcTy = CI->getOperand(0)->getType(); // A from above in isEliminableCastPair()
239 Type *MidTy = CI->getType(); // B from above in isEliminableCastPair()
242 Instruction::CastOps firstOp = Instruction::CastOps(CI->getOpcode()); in isEliminableCastPair()
274 if (const CastInst *CI = dyn_cast<CastInst>(V)) in ShouldOptimizeCast() local
275 if (isEliminableCastPair(CI, opc, Ty, DL)) in ShouldOptimizeCast()
288 Instruction *InstCombiner::commonCastTransforms(CastInst &CI) { in commonCastTransforms() argument
289 Value *Src = CI.getOperand(0); in commonCastTransforms()
295 isEliminableCastPair(CSrc, CI.getOpcode(), CI.getType(), DL)) { in commonCastTransforms()
298 return CastInst::Create(opc, CSrc->getOperand(0), CI.getType()); in commonCastTransforms()
304 if (Instruction *NV = FoldOpIntoSelect(CI, SI)) in commonCastTransforms()
311 if (!Src->getType()->isIntegerTy() || !CI.getType()->isIntegerTy() || in commonCastTransforms()
312 ShouldChangeType(CI.getType(), Src->getType())) in commonCastTransforms()
313 if (Instruction *NV = FoldOpIntoPhi(CI)) in commonCastTransforms()
382 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->getOperand(1))) { in canEvaluateTruncated() local
384 if (CI->getLimitedValue(BitWidth) < BitWidth) in canEvaluateTruncated()
392 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->getOperand(1))) { in canEvaluateTruncated() local
397 CI->getLimitedValue(BitWidth) < BitWidth) { in canEvaluateTruncated()
477 Instruction *InstCombiner::visitTrunc(TruncInst &CI) { in visitTrunc() argument
478 if (Instruction *Result = commonCastTransforms(CI)) in visitTrunc()
486 if (SelectInst *SI = dyn_cast<SelectInst>(CI.getOperand(0))) in visitTrunc()
492 if (SimplifyDemandedInstructionBits(CI)) in visitTrunc()
493 return &CI; in visitTrunc()
495 Value *Src = CI.getOperand(0); in visitTrunc()
496 Type *DestTy = CI.getType(), *SrcTy = Src->getType(); in visitTrunc()
503 canEvaluateTruncated(Src, DestTy, *this, &CI)) { in visitTrunc()
508 " to avoid cast: " << CI << '\n'); in visitTrunc()
511 return replaceInstUsesWith(CI, Res); in visitTrunc()
535 return replaceInstUsesWith(CI, Constant::getNullValue(DestTy)); in visitTrunc()
561 return CastInst::CreateIntegerCast(Shift, CI.getType(), true); in visitTrunc()
575 if (Instruction *I = foldVecTruncToExtElt(CI, *this, DL)) in visitTrunc()
583 Instruction *InstCombiner::transformZExtICmp(ICmpInst *ICI, Instruction &CI, in transformZExtICmp() argument
601 if (In->getType() != CI.getType()) in transformZExtICmp()
602 In = Builder->CreateIntCast(In, CI.getType(), false/*ZExt*/); in transformZExtICmp()
609 return replaceInstUsesWith(CI, In); in transformZExtICmp()
626 computeKnownBits(ICI->getOperand(0), KnownZero, KnownOne, 0, &CI); in transformZExtICmp()
636 Constant *Res = ConstantInt::get(Type::getInt1Ty(CI.getContext()), in transformZExtICmp()
638 Res = ConstantExpr::getZExt(Res, CI.getType()); in transformZExtICmp()
639 return replaceInstUsesWith(CI, Res); in transformZExtICmp()
656 if (CI.getType() == In->getType()) in transformZExtICmp()
657 return replaceInstUsesWith(CI, In); in transformZExtICmp()
658 return CastInst::CreateIntegerCast(In, CI.getType(), false/*ZExt*/); in transformZExtICmp()
666 if (ICI->isEquality() && CI.getType() == ICI->getOperand(0)->getType()) { in transformZExtICmp()
667 if (IntegerType *ITy = dyn_cast<IntegerType>(CI.getType())) { in transformZExtICmp()
674 computeKnownBits(LHS, KnownZeroLHS, KnownOneLHS, 0, &CI); in transformZExtICmp()
675 computeKnownBits(RHS, KnownZeroRHS, KnownOneRHS, 0, &CI); in transformZExtICmp()
697 return replaceInstUsesWith(CI, Result); in transformZExtICmp()
832 Instruction *InstCombiner::visitZExt(ZExtInst &CI) { in visitZExt() argument
835 if (CI.hasOneUse() && isa<TruncInst>(CI.user_back())) in visitZExt()
839 if (Instruction *Result = commonCastTransforms(CI)) in visitZExt()
844 if (SimplifyDemandedInstructionBits(CI)) in visitZExt()
845 return &CI; in visitZExt()
847 Value *Src = CI.getOperand(0); in visitZExt()
848 Type *SrcTy = Src->getType(), *DestTy = CI.getType(); in visitZExt()
856 canEvaluateZExtd(Src, DestTy, BitsToClear, *this, &CI)) { in visitZExt()
862 " to avoid zero extend: " << CI << '\n'); in visitZExt()
874 0, &CI)) in visitZExt()
875 return replaceInstUsesWith(CI, Res); in visitZExt()
894 unsigned DstSize = CI.getType()->getScalarSizeInBits(); in visitZExt()
903 return new ZExtInst(And, CI.getType()); in visitZExt()
912 Value *Trunc = Builder->CreateTrunc(A, CI.getType()); in visitZExt()
921 return transformZExtICmp(ICI, CI); in visitZExt()
930 (transformZExtICmp(LHS, CI, false) || in visitZExt()
931 transformZExtICmp(RHS, CI, false))) { in visitZExt()
932 Value *LCast = Builder->CreateZExt(LHS, CI.getType(), LHS->getName()); in visitZExt()
933 Value *RCast = Builder->CreateZExt(RHS, CI.getType(), RHS->getName()); in visitZExt()
943 X->getType() == CI.getType()) in visitZExt()
944 return BinaryOperator::CreateAnd(X, ConstantExpr::getZExt(C, CI.getType())); in visitZExt()
950 X->getType() == CI.getType()) { in visitZExt()
951 Constant *ZC = ConstantExpr::getZExt(C, CI.getType()); in visitZExt()
959 Value *New = Builder->CreateZExt(X, CI.getType()); in visitZExt()
960 return BinaryOperator::CreateXor(New, ConstantInt::get(CI.getType(), 1)); in visitZExt()
967 Instruction *InstCombiner::transformSExtICmp(ICmpInst *ICI, Instruction &CI) { in transformSExtICmp() argument
984 if (In->getType() != CI.getType()) in transformSExtICmp()
985 In = Builder->CreateIntCast(In, CI.getType(), true/*SExt*/); in transformSExtICmp()
989 return replaceInstUsesWith(CI, In); in transformSExtICmp()
1001 computeKnownBits(Op0, KnownZero, KnownOne, 0, &CI); in transformSExtICmp()
1010 ConstantInt::getAllOnesValue(CI.getType()) : in transformSExtICmp()
1011 ConstantInt::getNullValue(CI.getType()); in transformSExtICmp()
1012 return replaceInstUsesWith(CI, V); in transformSExtICmp()
1043 if (CI.getType() == In->getType()) in transformSExtICmp()
1044 return replaceInstUsesWith(CI, In); in transformSExtICmp()
1045 return CastInst::CreateIntegerCast(In, CI.getType(), true/*SExt*/); in transformSExtICmp()
1117 Instruction *InstCombiner::visitSExt(SExtInst &CI) { in visitSExt() argument
1120 if (CI.hasOneUse() && isa<TruncInst>(CI.user_back())) in visitSExt()
1123 if (Instruction *I = commonCastTransforms(CI)) in visitSExt()
1128 if (SimplifyDemandedInstructionBits(CI)) in visitSExt()
1129 return &CI; in visitSExt()
1131 Value *Src = CI.getOperand(0); in visitSExt()
1132 Type *SrcTy = Src->getType(), *DestTy = CI.getType(); in visitSExt()
1137 ComputeSignBit(Src, KnownZero, KnownOne, 0, &CI); in visitSExt()
1140 return replaceInstUsesWith(CI, ZExt); in visitSExt()
1151 " to avoid sign extend: " << CI << '\n'); in visitSExt()
1160 if (ComputeNumSignBits(Res, 0, &CI) > DestBitSize - SrcBitSize) in visitSExt()
1161 return replaceInstUsesWith(CI, Res); in visitSExt()
1183 return transformSExtICmp(ICI, CI); in visitSExt()
1203 BA == CA && A->getType() == CI.getType()) { in visitSExt()
1205 unsigned SrcDstSize = CI.getType()->getScalarSizeInBits(); in visitSExt()
1207 Constant *ShAmtV = ConstantInt::get(CI.getType(), ShAmt); in visitSExt()
1208 A = Builder->CreateShl(A, ShAmtV, CI.getName()); in visitSExt()
1256 Instruction *InstCombiner::visitFPTrunc(FPTruncInst &CI) { in visitFPTrunc() argument
1257 if (Instruction *I = commonCastTransforms(CI)) in visitFPTrunc()
1266 BinaryOperator *OpI = dyn_cast<BinaryOperator>(CI.getOperand(0)); in visitFPTrunc()
1274 unsigned DstWidth = CI.getType()->getFPMantissaWidth(); in visitFPTrunc()
1298 if (LHSOrig->getType() != CI.getType()) in visitFPTrunc()
1299 LHSOrig = Builder->CreateFPExt(LHSOrig, CI.getType()); in visitFPTrunc()
1300 if (RHSOrig->getType() != CI.getType()) in visitFPTrunc()
1301 RHSOrig = Builder->CreateFPExt(RHSOrig, CI.getType()); in visitFPTrunc()
1315 if (LHSOrig->getType() != CI.getType()) in visitFPTrunc()
1316 LHSOrig = Builder->CreateFPExt(LHSOrig, CI.getType()); in visitFPTrunc()
1317 if (RHSOrig->getType() != CI.getType()) in visitFPTrunc()
1318 RHSOrig = Builder->CreateFPExt(RHSOrig, CI.getType()); in visitFPTrunc()
1333 if (LHSOrig->getType() != CI.getType()) in visitFPTrunc()
1334 LHSOrig = Builder->CreateFPExt(LHSOrig, CI.getType()); in visitFPTrunc()
1335 if (RHSOrig->getType() != CI.getType()) in visitFPTrunc()
1336 RHSOrig = Builder->CreateFPExt(RHSOrig, CI.getType()); in visitFPTrunc()
1358 return CastInst::CreateFPCast(ExactResult, CI.getType()); in visitFPTrunc()
1365 CI.getType()); in visitFPTrunc()
1379 SelectInst *SI = dyn_cast<SelectInst>(CI.getOperand(0)); in visitFPTrunc()
1385 CI.getType()); in visitFPTrunc()
1387 CI.getType()); in visitFPTrunc()
1391 IntrinsicInst *II = dyn_cast<IntrinsicInst>(CI.getOperand(0)); in visitFPTrunc()
1398 CI.getType()); in visitFPTrunc()
1399 Type *IntrinsicType[] = { CI.getType() }; in visitFPTrunc()
1401 CI.getModule(), II->getIntrinsicID(), IntrinsicType); in visitFPTrunc()
1415 Instruction *InstCombiner::visitFPExt(CastInst &CI) { in visitFPExt() argument
1416 return commonCastTransforms(CI); in visitFPExt()
1485 Instruction *InstCombiner::visitUIToFP(CastInst &CI) { in visitUIToFP() argument
1486 return commonCastTransforms(CI); in visitUIToFP()
1489 Instruction *InstCombiner::visitSIToFP(CastInst &CI) { in visitSIToFP() argument
1490 return commonCastTransforms(CI); in visitSIToFP()
1493 Instruction *InstCombiner::visitIntToPtr(IntToPtrInst &CI) { in visitIntToPtr() argument
1497 unsigned AS = CI.getAddressSpace(); in visitIntToPtr()
1498 if (CI.getOperand(0)->getType()->getScalarSizeInBits() != in visitIntToPtr()
1500 Type *Ty = DL.getIntPtrType(CI.getContext(), AS); in visitIntToPtr()
1501 if (CI.getType()->isVectorTy()) // Handle vectors of pointers. in visitIntToPtr()
1502 Ty = VectorType::get(Ty, CI.getType()->getVectorNumElements()); in visitIntToPtr()
1504 Value *P = Builder->CreateZExtOrTrunc(CI.getOperand(0), Ty); in visitIntToPtr()
1505 return new IntToPtrInst(P, CI.getType()); in visitIntToPtr()
1508 if (Instruction *I = commonCastTransforms(CI)) in visitIntToPtr()
1515 Instruction *InstCombiner::commonPointerCastTransforms(CastInst &CI) { in commonPointerCastTransforms() argument
1516 Value *Src = CI.getOperand(0); in commonPointerCastTransforms()
1525 (!isa<AddrSpaceCastInst>(CI) || in commonPointerCastTransforms()
1531 CI.setOperand(0, GEP->getOperand(0)); in commonPointerCastTransforms()
1532 return &CI; in commonPointerCastTransforms()
1536 return commonCastTransforms(CI); in commonPointerCastTransforms()
1539 Instruction *InstCombiner::visitPtrToInt(PtrToIntInst &CI) { in visitPtrToInt() argument
1544 Type *Ty = CI.getType(); in visitPtrToInt()
1545 unsigned AS = CI.getPointerAddressSpace(); in visitPtrToInt()
1548 return commonPointerCastTransforms(CI); in visitPtrToInt()
1550 Type *PtrTy = DL.getIntPtrType(CI.getContext(), AS); in visitPtrToInt()
1554 Value *P = Builder->CreatePtrToInt(CI.getOperand(0), PtrTy); in visitPtrToInt()
1716 ConstantInt *CI = dyn_cast<ConstantInt>(I->getOperand(1)); in collectInsertionElements() local
1717 if (!CI) return false; in collectInsertionElements()
1718 Shift += CI->getZExtValue(); in collectInsertionElements()
1742 static Value *optimizeIntegerToVectorInsertions(BitCastInst &CI, in optimizeIntegerToVectorInsertions() argument
1744 VectorType *DestVecTy = cast<VectorType>(CI.getType()); in optimizeIntegerToVectorInsertions()
1745 Value *IntInput = CI.getOperand(0); in optimizeIntegerToVectorInsertions()
1756 Value *Result = Constant::getNullValue(CI.getType()); in optimizeIntegerToVectorInsertions()
1792 Instruction *InstCombiner::visitBitCast(BitCastInst &CI) { in visitBitCast() argument
1795 Value *Src = CI.getOperand(0); in visitBitCast()
1797 Type *DestTy = CI.getType(); in visitBitCast()
1802 return replaceInstUsesWith(CI, Src); in visitBitCast()
1814 if (Instruction *V = PromoteCastOfAllocation(CI, *AI)) in visitBitCast()
1846 Constant::getNullValue(Type::getInt32Ty(CI.getContext()))); in visitBitCast()
1866 if (Value *V = optimizeIntegerToVectorInsertions(CI, *this)) in visitBitCast()
1867 return replaceInstUsesWith(CI, V); in visitBitCast()
1878 Constant::getNullValue(Type::getInt32Ty(CI.getContext()))); in visitBitCast()
1885 dyn_cast<InsertElementInst>(CI.getOperand(0))) in visitBitCast()
1915 if (Instruction *I = canonicalizeBitCastExtElt(CI, *this, DL)) in visitBitCast()
1919 return commonPointerCastTransforms(CI); in visitBitCast()
1920 return commonCastTransforms(CI); in visitBitCast()
1923 Instruction *InstCombiner::visitAddrSpaceCast(AddrSpaceCastInst &CI) { in visitAddrSpaceCast() argument
1927 Value *Src = CI.getOperand(0); in visitAddrSpaceCast()
1929 PointerType *DestTy = cast<PointerType>(CI.getType()->getScalarType()); in visitAddrSpaceCast()
1934 if (VectorType *VT = dyn_cast<VectorType>(CI.getType())) { in visitAddrSpaceCast()
1940 return new AddrSpaceCastInst(NewBitCast, CI.getType()); in visitAddrSpaceCast()
1943 return commonPointerCastTransforms(CI); in visitAddrSpaceCast()