Lines Matching refs:ConstantInt
40 static ConstantInt *getOne(Constant *C) { in getOne()
41 return ConstantInt::get(cast<IntegerType>(C->getType()), 1); in getOne()
44 static ConstantInt *ExtractElement(Constant *V, Constant *Idx) { in ExtractElement()
45 return cast<ConstantInt>(ConstantExpr::getExtractElement(V, Idx)); in ExtractElement()
48 static bool HasAddOverflow(ConstantInt *Result, in HasAddOverflow()
49 ConstantInt *In1, ConstantInt *In2, in HasAddOverflow()
67 Constant *Idx = ConstantInt::get(Type::getInt32Ty(In1->getContext()), i); in AddWithOverflow()
77 return HasAddOverflow(cast<ConstantInt>(Result), in AddWithOverflow()
78 cast<ConstantInt>(In1), cast<ConstantInt>(In2), in AddWithOverflow()
82 static bool HasSubOverflow(ConstantInt *Result, in HasSubOverflow()
83 ConstantInt *In1, ConstantInt *In2, in HasSubOverflow()
102 Constant *Idx = ConstantInt::get(Type::getInt32Ty(In1->getContext()), i); in SubWithOverflow()
112 return HasSubOverflow(cast<ConstantInt>(Result), in SubWithOverflow()
113 cast<ConstantInt>(In1), cast<ConstantInt>(In2), in SubWithOverflow()
129 static bool isSignBitCheck(ICmpInst::Predicate Pred, ConstantInt *RHS, in isSignBitCheck()
157 static bool isSignTest(ICmpInst::Predicate &Pred, const ConstantInt *RHS) { in isSignTest()
181 static bool isHighOnes(const ConstantInt *CI) { in isHighOnes()
236 CmpInst &ICI, ConstantInt *AndCst) { in FoldCmpLoadFromIndexedGlobal()
249 !isa<ConstantInt>(GEP->getOperand(1)) || in FoldCmpLoadFromIndexedGlobal()
250 !cast<ConstantInt>(GEP->getOperand(1))->isZero() || in FoldCmpLoadFromIndexedGlobal()
261 ConstantInt *Idx = dyn_cast<ConstantInt>(GEP->getOperand(i)); in FoldCmpLoadFromIndexedGlobal()
336 if (!isa<ConstantInt>(C)) return nullptr; in FoldCmpLoadFromIndexedGlobal()
340 bool IsTrueForElt = !cast<ConstantInt>(C)->isZero(); in FoldCmpLoadFromIndexedGlobal()
413 Value *FirstTrueIdx = ConstantInt::get(Idx->getType(), FirstTrueElement); in FoldCmpLoadFromIndexedGlobal()
421 Value *SecondTrueIdx = ConstantInt::get(Idx->getType(), SecondTrueElement); in FoldCmpLoadFromIndexedGlobal()
433 Value *FirstFalseIdx = ConstantInt::get(Idx->getType(), FirstFalseElement); in FoldCmpLoadFromIndexedGlobal()
441 Value *SecondFalseIdx = ConstantInt::get(Idx->getType(),SecondFalseElement); in FoldCmpLoadFromIndexedGlobal()
453 Value *Offs = ConstantInt::get(Idx->getType(), -FirstTrueElement); in FoldCmpLoadFromIndexedGlobal()
457 Value *End = ConstantInt::get(Idx->getType(), in FoldCmpLoadFromIndexedGlobal()
467 Value *Offs = ConstantInt::get(Idx->getType(), -FirstFalseElement); in FoldCmpLoadFromIndexedGlobal()
471 Value *End = ConstantInt::get(Idx->getType(), in FoldCmpLoadFromIndexedGlobal()
493 V = Builder->CreateLShr(ConstantInt::get(Ty, MagicBitvector), V); in FoldCmpLoadFromIndexedGlobal()
494 V = Builder->CreateAnd(ConstantInt::get(Ty, 1), V); in FoldCmpLoadFromIndexedGlobal()
495 return new ICmpInst(ICmpInst::ICMP_NE, V, ConstantInt::get(Ty, 0)); in FoldCmpLoadFromIndexedGlobal()
524 if (ConstantInt *CI = dyn_cast<ConstantInt>(GEP->getOperand(i))) { in EvaluateGEPOffsetExpression()
552 ConstantInt *CI = dyn_cast<ConstantInt>(GEP->getOperand(i)); in EvaluateGEPOffsetExpression()
601 Constant *OffsetVal = ConstantInt::get(IntPtrTy, NewOffs); in EvaluateGEPOffsetExpression()
746 NewInsts[Base] = ConstantInt::getNullValue(IndexType); in rewriteGEPAsOffset()
784 if (isa<ConstantInt>(Op) && dyn_cast<ConstantInt>(Op)->isZero()) in rewriteGEPAsOffset()
853 Constant *Index = ConstantInt::getNullValue(IndexType); in getAsConstantIndexedAddress()
1133 ConstantInt::get(CmpTy, !CmpInst::isTrueWhenEqual(ICI.getPredicate()))); in FoldAllocaCmp()
1138 Value *X, ConstantInt *CI, in FoldICmpAddOpCst()
1149 ConstantExpr::getSub(ConstantInt::getAllOnesValue(CI->getType()), CI); in FoldICmpAddOpCst()
1160 ConstantInt *SMax = ConstantInt::get(X->getContext(), in FoldICmpAddOpCst()
1187 ConstantInt *DivRHS) { in FoldICmpDivCst()
1188 ConstantInt *CmpRHS = cast<ConstantInt>(ICI.getOperand(1)); in FoldICmpDivCst()
1229 ConstantInt *RangeSize = DivI->isExact() ? getOne(Prod) : DivRHS; in FoldICmpDivCst()
1265 ConstantInt *DivNeg =cast<ConstantInt>(ConstantExpr::getNeg(RangeSize)); in FoldICmpDivCst()
1271 RangeSize = cast<ConstantInt>(ConstantExpr::getNeg(RangeSize)); in FoldICmpDivCst()
1275 HiBound = cast<ConstantInt>(ConstantExpr::getNeg(RangeSize)); in FoldICmpDivCst()
1343 ConstantInt *ShAmt) { in FoldICmpShrCst()
1344 const APInt &CmpRHSV = cast<ConstantInt>(ICI.getOperand(1))->getValue(); in FoldICmpShrCst()
1371 ConstantInt::get(Shr->getType(), APInt::getOneBitSet(TypeBits, ShAmtVal)); in FoldICmpShrCst()
1389 Instruction *Res = FoldICmpDivCst(ICI, TheDiv, cast<ConstantInt>(DivCst)); in FoldICmpShrCst()
1397 ConstantInt *ShiftedCmpRHS = Builder->getInt(Comp); in FoldICmpShrCst()
1431 ConstantInt *CI1, in FoldICmpCstShrCst()
1432 ConstantInt *CI2) { in FoldICmpCstShrCst()
1438 return replaceInstUsesWith(I, ConstantInt::get(I.getType(), IsTrue)); in FoldICmpCstShrCst()
1466 ConstantInt::get(A->getType(), AP2.logBase2())); in FoldICmpCstShrCst()
1469 return getICmp(I.ICMP_EQ, A, ConstantInt::getNullValue(A->getType())); in FoldICmpCstShrCst()
1482 return getICmp(I.ICMP_UGE, A, ConstantInt::get(A->getType(), Shift)); in FoldICmpCstShrCst()
1483 return getICmp(I.ICMP_EQ, A, ConstantInt::get(A->getType(), Shift)); in FoldICmpCstShrCst()
1485 return getICmp(I.ICMP_EQ, A, ConstantInt::get(A->getType(), Shift)); in FoldICmpCstShrCst()
1495 ConstantInt *CI1, in FoldICmpCstShlCst()
1496 ConstantInt *CI2) { in FoldICmpCstShlCst()
1502 return replaceInstUsesWith(I, ConstantInt::get(I.getType(), IsTrue)); in FoldICmpCstShlCst()
1522 ConstantInt::get(A->getType(), AP2.getBitWidth() - AP2TrailingZeros)); in FoldICmpCstShlCst()
1525 return getICmp(I.ICMP_EQ, A, ConstantInt::getNullValue(A->getType())); in FoldICmpCstShlCst()
1531 return getICmp(I.ICMP_EQ, A, ConstantInt::get(A->getType(), Shift)); in FoldICmpCstShlCst()
1540 ConstantInt *RHS) { in visitICmpInstWithInstAndIntCst()
1551 ConstantInt::get(V->getType(), 1)); in visitICmpInstWithInstAndIntCst()
1573 if (ConstantInt *XorCst = dyn_cast<ConstantInt>(LHSI->getOperand(1))) { in visitICmpInstWithInstAndIntCst()
1639 if (LHSI->hasOneUse() && isa<ConstantInt>(LHSI->getOperand(1)) && in visitICmpInstWithInstAndIntCst()
1641 ConstantInt *AndCst = cast<ConstantInt>(LHSI->getOperand(1)); in visitICmpInstWithInstAndIntCst()
1686 ConstantInt *ShAmt; in visitICmpInstWithInstAndIntCst()
1687 ShAmt = Shift ? dyn_cast<ConstantInt>(Shift->getOperand(1)) : nullptr; in visitICmpInstWithInstAndIntCst()
1716 ConstantInt *ShiftedAndCst = in visitICmpInstWithInstAndIntCst()
1717 cast<ConstantInt>(ConstantExpr::getShl(AndCst, ShAmt)); in visitICmpInstWithInstAndIntCst()
1718 ConstantInt *ShiftedRHSCst = in visitICmpInstWithInstAndIntCst()
1719 cast<ConstantInt>(ConstantExpr::getShl(RHS, ShAmt)); in visitICmpInstWithInstAndIntCst()
1840 !LI->isVolatile() && isa<ConstantInt>(LHSI->getOperand(1))) { in visitICmpInstWithInstAndIntCst()
1841 ConstantInt *C = cast<ConstantInt>(LHSI->getOperand(1)); in visitICmpInstWithInstAndIntCst()
1859 if (auto *CI = dyn_cast<ConstantInt>(LHSI->getOperand(1))) { in visitICmpInstWithInstAndIntCst()
1881 ConstantInt::get(V->getType(), 1)); in visitICmpInstWithInstAndIntCst()
1905 ConstantInt *Val = dyn_cast<ConstantInt>(LHSI->getOperand(1)); in visitICmpInstWithInstAndIntCst()
1923 ConstantInt *ShAmt = dyn_cast<ConstantInt>(LHSI->getOperand(1)); in visitICmpInstWithInstAndIntCst()
1953 ConstantInt::get(RHS->getType(), RHSLog2)); in visitICmpInstWithInstAndIntCst()
1959 ConstantInt::get(RHS->getType(), TypeBits-1)); in visitICmpInstWithInstAndIntCst()
1964 ConstantInt::get(RHS->getType(), TypeBits-1)); in visitICmpInstWithInstAndIntCst()
1970 ConstantInt::get(RHS->getType(), TypeBits-1)); in visitICmpInstWithInstAndIntCst()
1976 ConstantInt::get(RHS->getType(), TypeBits-1)); in visitICmpInstWithInstAndIntCst()
1981 Pred, X, ConstantInt::get(RHS->getType(), RHSV.logBase2())); in visitICmpInstWithInstAndIntCst()
2044 Constant *Mask = ConstantInt::get(LHSI->getOperand(0)->getType(), in visitICmpInstWithInstAndIntCst()
2065 ConstantInt::get(RHS->getType(), Amt)), in visitICmpInstWithInstAndIntCst()
2079 if (ConstantInt *ShAmt = dyn_cast<ConstantInt>(LHSI->getOperand(1))) { in visitICmpInstWithInstAndIntCst()
2093 if (ConstantInt *DivLHS = dyn_cast<ConstantInt>(LHSI->getOperand(0))) { in visitICmpInstWithInstAndIntCst()
2103 ConstantInt::get(X->getType(), C2.udiv(C1 + 1))); in visitICmpInstWithInstAndIntCst()
2109 ConstantInt::get(X->getType(), C2.udiv(C1))); in visitICmpInstWithInstAndIntCst()
2120 if (ConstantInt *DivRHS = dyn_cast<ConstantInt>(LHSI->getOperand(1))) in visitICmpInstWithInstAndIntCst()
2127 ConstantInt *LHSC = dyn_cast<ConstantInt>(LHSI->getOperand(0)); in visitICmpInstWithInstAndIntCst()
2153 ConstantInt *LHSC = dyn_cast<ConstantInt>(LHSI->getOperand(1)); in visitICmpInstWithInstAndIntCst()
2209 if (RHSV == 0 && isa<ConstantInt>(BO->getOperand(1)) &&BO->hasOneUse()){ in visitICmpInstWithInstAndIntCst()
2210 const APInt &V = cast<ConstantInt>(BO->getOperand(1))->getValue(); in visitICmpInstWithInstAndIntCst()
2222 if (ConstantInt *BOp1C = dyn_cast<ConstantInt>(BO->getOperand(1))) { in visitICmpInstWithInstAndIntCst()
2258 if (ConstantInt *BOp0C = dyn_cast<ConstantInt>(BO->getOperand(0))) { in visitICmpInstWithInstAndIntCst()
2272 if (ConstantInt *BOC = dyn_cast<ConstantInt>(BO->getOperand(1))) { in visitICmpInstWithInstAndIntCst()
2289 if (ConstantInt *BOC = dyn_cast<ConstantInt>(BO->getOperand(1))) { in visitICmpInstWithInstAndIntCst()
2326 if (ConstantInt *BOC = dyn_cast<ConstantInt>(BO->getOperand(1))) { in visitICmpInstWithInstAndIntCst()
2352 ICI.setOperand(1, ConstantInt::get(RHS->getType(), 0)); in visitICmpInstWithInstAndIntCst()
2469 if (isSignedCmp || !isSignedExt || !isa<ConstantInt>(C)) in visitICmpInstWithCastAndCast()
2496 ConstantInt *CI2, ConstantInt *CI1, in ProcessUGT_ADDCST_ADD()
2735 if (ConstantInt *CI = dyn_cast<ConstantInt>(BO->getOperand(1))) { in ProcessUMulZExtIdiom()
2764 ConstantInt *CI; in ProcessUMulZExtIdiom()
2782 if (ConstantInt *CI = dyn_cast<ConstantInt>(OtherVal)) { in ProcessUMulZExtIdiom()
2794 if (ConstantInt *CI = dyn_cast<ConstantInt>(OtherVal)) { in ProcessUMulZExtIdiom()
2805 if (ConstantInt *CI = dyn_cast<ConstantInt>(OtherVal)) { in ProcessUMulZExtIdiom()
2817 if (ConstantInt *CI = dyn_cast<ConstantInt>(OtherVal)) { in ProcessUMulZExtIdiom()
2858 ConstantInt *CI = cast<ConstantInt>(BO->getOperand(1)); in ProcessUMulZExtIdiom()
2914 ConstantInt *CI = dyn_cast<ConstantInt>(I.getOperand(1)); in DemandedBitsLHSMask()
3118 auto *CI = dyn_cast<ConstantInt>(Op1C); in canonicalizeCmpWithConstant()
3136 auto *CI = dyn_cast<ConstantInt>(Elt); in canonicalizeCmpWithConstant()
3147 Constant *OneOrNegOne = ConstantInt::get(Op1Type, IsLE ? 1 : -1, true); in canonicalizeCmpWithConstant()
3246 if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) { in visitICmpInst()
3262 ConstantInt *CI2; // I = icmp ugt (add (add A, B), CI2), CI in visitICmpInst()
3312 ConstantInt *CI2; in visitICmpInst()
3337 ConstantInt *CI2; in visitICmpInst()
3405 ConstantInt::get(Op0->getType(), Op0Min), Op1); in visitICmpInst()
3408 ConstantInt::get(Op1->getType(), Op1Min)); in visitICmpInst()
3416 return replaceInstUsesWith(I, ConstantInt::getFalse(I.getType())); in visitICmpInst()
3425 ConstantInt *LHSC = nullptr; in visitICmpInst()
3439 ConstantInt::get(X->getType(), CmpVal)); in visitICmpInst()
3443 ConstantInt::get(X->getType(), CmpVal)); in visitICmpInst()
3453 ConstantInt::get(X->getType(), in visitICmpInst()
3460 return replaceInstUsesWith(I, ConstantInt::getTrue(I.getType())); in visitICmpInst()
3469 ConstantInt *LHSC = nullptr; in visitICmpInst()
3483 ConstantInt::get(X->getType(), CmpVal)); in visitICmpInst()
3487 ConstantInt::get(X->getType(), CmpVal)); in visitICmpInst()
3497 ConstantInt::get(X->getType(), in visitICmpInst()
3504 return replaceInstUsesWith(I, ConstantInt::getTrue(I.getType())); in visitICmpInst()
3506 return replaceInstUsesWith(I, ConstantInt::getFalse(I.getType())); in visitICmpInst()
3509 if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) { in visitICmpInst()
3522 return replaceInstUsesWith(I, ConstantInt::getTrue(I.getType())); in visitICmpInst()
3524 return replaceInstUsesWith(I, ConstantInt::getFalse(I.getType())); in visitICmpInst()
3528 if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) { in visitICmpInst()
3541 return replaceInstUsesWith(I, ConstantInt::getTrue(I.getType())); in visitICmpInst()
3543 return replaceInstUsesWith(I, ConstantInt::getFalse(I.getType())); in visitICmpInst()
3546 if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) { in visitICmpInst()
3554 return replaceInstUsesWith(I, ConstantInt::getTrue(I.getType())); in visitICmpInst()
3556 return replaceInstUsesWith(I, ConstantInt::getFalse(I.getType())); in visitICmpInst()
3560 if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) { in visitICmpInst()
3567 assert(!isa<ConstantInt>(Op1) && "ICMP_SGE with ConstantInt not folded!"); in visitICmpInst()
3569 return replaceInstUsesWith(I, ConstantInt::getTrue(I.getType())); in visitICmpInst()
3571 return replaceInstUsesWith(I, ConstantInt::getFalse(I.getType())); in visitICmpInst()
3574 assert(!isa<ConstantInt>(Op1) && "ICMP_SLE with ConstantInt not folded!"); in visitICmpInst()
3576 return replaceInstUsesWith(I, ConstantInt::getTrue(I.getType())); in visitICmpInst()
3578 return replaceInstUsesWith(I, ConstantInt::getFalse(I.getType())); in visitICmpInst()
3581 assert(!isa<ConstantInt>(Op1) && "ICMP_UGE with ConstantInt not folded!"); in visitICmpInst()
3583 return replaceInstUsesWith(I, ConstantInt::getTrue(I.getType())); in visitICmpInst()
3585 return replaceInstUsesWith(I, ConstantInt::getFalse(I.getType())); in visitICmpInst()
3588 assert(!isa<ConstantInt>(Op1) && "ICMP_ULE with ConstantInt not folded!"); in visitICmpInst()
3590 return replaceInstUsesWith(I, ConstantInt::getTrue(I.getType())); in visitICmpInst()
3592 return replaceInstUsesWith(I, ConstantInt::getFalse(I.getType())); in visitICmpInst()
3619 if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) { in visitICmpInst()
3662 ConstantInt *CI = nullptr; in visitICmpInst()
3665 CI = dyn_cast<ConstantInt>(Op1); in visitICmpInst()
3669 CI = dyn_cast<ConstantInt>(Op2); in visitICmpInst()
3816 if (ConstantInt *RHSC = dyn_cast_or_null<ConstantInt>(B)) in visitICmpInst()
3907 if (ConstantInt *C1 = dyn_cast<ConstantInt>(B)) in visitICmpInst()
3908 if (ConstantInt *C2 = dyn_cast<ConstantInt>(D)) { in visitICmpInst()
3915 ConstantInt *C3 = Builder->getInt(AP1 - AP2); in visitICmpInst()
3919 ConstantInt *C3 = Builder->getInt(AP2 - AP1); in visitICmpInst()
3966 if (ConstantInt *RHSC = dyn_cast<ConstantInt>(Op1)) in visitICmpInst()
3987 return replaceInstUsesWith(I, ConstantInt::getFalse(I.getType())); in visitICmpInst()
3989 return replaceInstUsesWith(I, ConstantInt::getTrue(I.getType())); in visitICmpInst()
4013 if (ConstantInt *CI = dyn_cast<ConstantInt>(BO0->getOperand(1))) { in visitICmpInst()
4036 if (ConstantInt *CI = dyn_cast<ConstantInt>(BO0->getOperand(1))) { in visitICmpInst()
4041 ConstantInt *Mask = ConstantInt::get(I.getContext(), in visitICmpInst()
4104 if (ConstantInt *RHSC = dyn_cast<ConstantInt>(Op1)) in visitICmpInst()
4144 ConstantInt *C1, *C2; in visitICmpInst()
4194 ConstantInt *Cst1; in visitICmpInst()
4284 Value *X; ConstantInt *Cst; in visitICmpInst()