Lines Matching refs:Constant
39 static ConstantInt *getOne(Constant *C) {
43 static ConstantInt *ExtractElement(Constant *V, Constant *Idx) {
60 static bool AddWithOverflow(Constant *&Result, Constant *In1,
61 Constant *In2, bool IsSigned = false) {
66 Constant *Idx = ConstantInt::get(Type::getInt32Ty(In1->getContext()), i);
95 static bool SubWithOverflow(Constant *&Result, Constant *In1,
96 Constant *In2, bool IsSigned = false) {
101 Constant *Idx = ConstantInt::get(Type::getInt32Ty(In1->getContext()), i);
170 // isHighOnes - Return true if the constant is of the form 1+0+.
221 /// where GV is a global variable with a constant initializer. Try to simplify
225 /// If AndCst is non-null, then the loaded value is masked with that constant
230 Constant *Init = GV->getInitializer();
240 // Require: GEP GV, 0, i {{, constant indices}}
244 isa<Constant>(GEP->getOperand(2)))
301 Constant *CompareRHS = cast<Constant>(ICI.getOperand(1));
303 Constant *Elt = Init->getAggregateElement(i);
314 Constant *C = ConstantFoldCompareInstOperands(ICI.getPredicate(), Elt,
510 // any constant indices are a multiple of its scale, then we can compute this
518 // Compute the aggregate offset of constant indices.
534 // If there are no variable indices, we must have a constant offset, just
548 // Compute the aggregate offset of constant indices.
582 // To do this transformation, any constant index must be a multiple of the
594 Constant *OffsetVal = ConstantInt::get(IntPtrTy, NewOffs);
628 Constant::getNullValue(Offset->getType()));
648 // and both GEPs have only constant indices or just one use, then fold
721 // the result to fold to a constant!
751 unsigned MaxIter = 32; // Break cycles and bound to constant-time.
854 Constant *C = Builder->getInt(CI->getValue()-1);
890 Constant *Prod = ConstantExpr::getMul(CmpRHS, DivRHS);
913 Constant *LoBound = nullptr, *HiBound = nullptr;
1044 Constant *DivCst =
1079 Constant *Cst = Builder->getInt1(IsICMP_NE);
1092 Constant *Mask = Builder->getInt(Val);
1322 // We can do this transformation if either the AND constant does not
1402 Constant *NewCst;
1420 Constant *NewAndCst;
1438 !isa<Constant>(Shift->getOperand(0))) {
1464 Constant *One = cast<Constant>(LHSI->getOperand(1));
1477 if (auto *C = dyn_cast<Constant>(Y)) {
1505 Constant::getNullValue(RHS->getType()));
1543 Trunc, Constant::getNullValue(NTy));
1566 Constant::getNullValue(P->getType()));
1568 Constant::getNullValue(Q->getType()));
1591 Constant::getNullValue(RHS->getType()));
1671 Constant *Comp =
1676 Constant *Cst = Builder->getInt1(IsICMP_NE);
1695 Constant *Mask = Builder->getInt(APInt::getLowBitsSet(TypeBits,
1712 Constant::getNullValue(RHS->getType()));
1719 Constant *Mask = ConstantInt::get(LHSI->getOperand(0)->getType(),
1725 And, Constant::getNullValue(And->getType()));
1733 // smaller constant, which will be target friendly.
1738 Constant *NCI = ConstantExpr::getTrunc(
1752 // Handle equality comparisons of shift-by-constant.
1854 // Simplify icmp_eq and icmp_ne instructions with integer constant RHS.
1858 // If the first operand is (add|sub|and|or|xor|rem) with a constant, and
1859 // the second operand is a constant, simplify a bit.
1871 Constant::getNullValue(BO->getType()));
1900 if (Constant *BOC = dyn_cast<Constant>(BO->getOperand(1))) {
1922 // If bits are being or'd in that are not present in the constant we
1925 Constant *NotCI = ConstantExpr::getNot(RHS);
1942 Constant::getNullValue(RHS->getType()));
1951 Constant *Zero = Constant::getNullValue(X->getType());
1960 Constant *NegX = ConstantExpr::getNeg(BOC);
1975 Constant::getNullValue(RHS->getType()));
2040 } else if (Constant *RHSC = dyn_cast<Constant>(ICI.getOperand(1)))
2080 // If we aren't dealing with a constant on the RHS, exit early
2085 // Compute the constant that would happen if we truncated to SrcTy then
2087 Constant *Res1 = ConstantExpr::getTrunc(CI, SrcTy);
2088 Constant *Res2 = ConstantExpr::getCast(LHSCI->getOpcode(),
2091 // If the re-extended constant didn't change...
2106 // The re-extended constant changed so the constant cannot be represented
2119 Constant *NegOne = Constant::getAllOnesValue(SrcTy);
2142 // with a narrower add, and discard the add-with-constant that is part of the
2145 // In order to eliminate the add-with-constant, the compare can be its only
2172 // llvm.sadd.with.overflow, the only uses allowed are the add-with-constant
2218 Value *&Result, Constant *&Overflow) {
2219 if (OrigI.isCommutative() && isa<Constant>(LHS) && !isa<Constant>(RHS))
2222 auto SetResult = [&](Value *OpResult, Constant *OverflowVal, bool ReuseName) {
2548 // DemandedBitsLHSMask - When performing a comparison against a constant,
2708 /// Similar when the first operand of the select is a constant or/and
2832 // See if we are doing a comparison with a constant.
2963 // figured out that the LHS is a constant. Just constant fold this now so
2965 if (!isa<Constant>(Op0) && Op0Min == Op0Max)
2968 if (!isa<Constant>(Op1) && Op1Min == Op1Max)
2985 // If the LHS is an AND with the same constant, look through it.
3029 // If the LHS is an AND with the same constant, look through it.
3079 Constant::getAllOnesValue(Op0->getType()));
3098 Constant::getNullValue(Op0->getType()));
3179 // See if we are doing a comparison between a constant and an instruction that
3190 // Handle icmp with constant (but not simple integer constant) RHS
3191 if (Constant *RHSC = dyn_cast<Constant>(Op1)) {
3199 Constant::getNullValue(LHSI->getOperand(0)->getType()));
3210 // If either operand of the select is a constant, we can fold the
3212 // constant folded and the select turned into a bitwise or.
3215 if (Constant *C = dyn_cast<Constant>(LHSI->getOperand(1))) {
3219 if (Constant *C = dyn_cast<Constant>(LHSI->getOperand(2))) {
3226 // fold to a constant (in which case the icmp is replaced with a select
3240 // When Op1 is constant try replacing select with second operand.
3241 // Otherwise Op2 is constant and try replacing select with first
3262 Constant::getNullValue(LHSI->getOperand(0)->getType()));
3304 (isa<Constant>(Op1) || isa<BitCastInst>(Op1))) {
3314 // If Op1 is a constant, we can fold the cast into the constant.
3316 if (Constant *Op1C = dyn_cast<Constant>(Op1)) {
3333 // with a constant or another cast from the same type.
3334 if (isa<Constant>(Op1) || isa<CastInst>(Op1))
3371 Constant::getNullValue(Op1->getType()));
3375 return new ICmpInst(Pred, Constant::getNullValue(Op0->getType()),
3485 return new ICmpInst(Pred, Constant::getNullValue(Op1->getType()), B);
3489 return new ICmpInst(Pred, D, Constant::getNullValue(Op0->getType()));
3534 Constant::getAllOnesValue(SRem->getType()));
3538 Constant::getNullValue(SRem->getType()));
3623 auto *Zero = Constant::getNullValue(BO0->getType());
3654 Constant *Overflow;
3680 Constant::getNullValue(A->getType()));
3688 Constant *NC = Builder->getInt(C1->getValue() ^ C2->getValue());
3706 Constant::getNullValue(A->getType()));
3728 I.setOperand(1, Constant::getNullValue(Op1->getType()));
3778 Constant::getNullValue(Cst1->getType()));
3840 Constant *RHSC) {
3859 // If the floating point constant isn't an integer value, we know if we will
3874 // TODO: If the constant is exactly representable, is it always OK to do
3904 // will always come through as an integer value and we know the constant is
3943 // See if the FP constant is too large for the integer. For example,
3997 // Okay, now we know that the FP constant fits in the range [SMIN, SMAX] or
4001 Constant *RHSInt = LHSUnsigned
4104 I.setOperand(1, Constant::getNullValue(Op0->getType()));
4113 I.setOperand(1, Constant::getNullValue(Op0->getType()));
4131 // Handle fcmp with constant RHS
4132 if (Constant *RHSC = dyn_cast<Constant>(Op1)) {