Home | History | Annotate | Download | only in Analysis

Lines Matching full:constant

11 // that do not require creating new instructions.  This does constant folding
12 // ("add i32 1, 1" -> "2") but can also handle non-constant operands, either
13 // returning a constant ("and i32 %x, 0" -> "0") or an already existing value
64 static Constant *getFalse(Type *Ty) {
67 return Constant::getNullValue(Ty);
72 static Constant *getTrue(Type *Ty) {
75 return Constant::getAllOnesValue(Ty);
501 SimplifyXorInst(Cond, Constant::getAllOnesValue(Cond->getType()),
594 if (Constant *CLHS = dyn_cast<Constant>(Op0)) {
595 if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
596 Constant *Ops[] = { CLHS, CRHS };
601 // Canonicalize the constant to the RHS.
624 return Constant::getAllOnesValue(Op0->getType());
660 /// \brief Compute the base pointer and cumulative constant offsets for V.
662 /// This strips all constant offsets off of V, leaving it the base pointer, and
663 /// accumulates the total constant offset applied in the returned constant. It
664 /// returns 0 if V is not a pointer, and returns the constant '0' if there are
665 /// no constant offsets applied.
670 static Constant *stripAndComputeConstantOffsets(const DataLayout *TD,
704 Constant *OffsetIntPtr = ConstantInt::get(IntPtrTy, Offset);
711 /// \brief Compute the constant difference between two pointer values.
712 /// If the difference is not a constant, returns zero.
713 static Constant *computePointerDifference(const DataLayout *TD,
715 Constant *LHSOffset = stripAndComputeConstantOffsets(TD, LHS);
716 Constant *RHSOffset = stripAndComputeConstantOffsets(TD, RHS);
718 // If LHS and RHS are not related via constant offsets to the same base
734 if (Constant *CLHS = dyn_cast<Constant>(Op0))
735 if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
736 Constant *Ops[] = { CLHS, CRHS };
752 return Constant::getNullValue(Op0->getType());
832 if (Constant *Result = computePointerDifference(Q.TD, X, Y))
868 if (Constant *CLHS = dyn_cast<Constant>(Op0)) {
869 if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
870 Constant *Ops[] = { CLHS, CRHS };
875 // Canonicalize the constant to the RHS.
900 return Constant::getNullValue(Op0->getType());
910 if (Constant *CLHS = dyn_cast<Constant>(Op0)) {
911 if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
912 Constant *Ops[] = { CLHS, CRHS };
938 return Constant::getNullValue(Op0->getType());
948 if (Constant *CLHS = dyn_cast<Constant>(Op0)) {
949 if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
950 Constant *Ops[] = { CLHS, CRHS };
955 // Canonicalize the constant to the RHS.
974 if (Constant *CLHS = dyn_cast<Constant>(Op0)) {
975 if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
976 Constant *Ops[] = { CLHS, CRHS };
981 // Canonicalize the constant to the RHS.
987 return Constant::getNullValue(Op0->getType());
1065 if (Constant *C0 = dyn_cast<Constant>(Op0)) {
1066 if (Constant *C1 = dyn_cast<Constant>(Op1)) {
1067 Constant *Ops[] = { C0, C1 };
1080 return Constant::getNullValue(Op0->getType());
1116 return Constant::getNullValue(Op0->getType());
1188 if (Constant *C0 = dyn_cast<Constant>(Op0)) {
1189 if (Constant *C1 = dyn_cast<Constant>(Op1)) {
1190 Constant *Ops[] = { C0, C1 };
1201 return Constant::getNullValue(Op0->getType());
1213 return Constant::getNullValue(Op0->getType());
1217 return Constant::getNullValue(Op0->getType());
1221 return Constant::getNullValue(Op0->getType());
1293 if (Constant *C0 = dyn_cast<Constant>(Op0)) {
1294 if (Constant *C1 = dyn_cast<Constant>(Op1)) {
1295 Constant *Ops[] = { C0, C1 };
1342 return Constant::getNullValue(Op0->getType());
1367 return Constant::getNullValue(Op0->getType());
1371 return Constant::getNullValue(Op0->getType());
1399 return Constant::getNullValue(Op0->getType());
1407 return Constant::getAllOnesValue(Op0->getType());
1430 if (Constant *CLHS = dyn_cast<Constant>(Op0)) {
1431 if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
1432 Constant *Ops[] = { CLHS, CRHS };
1437 // Canonicalize the constant to the RHS.
1443 return Constant::getNullValue(Op0->getType());
1460 return Constant::getNullValue(Op0->getType());
1529 if (Constant *CLHS = dyn_cast<Constant>(Op0)) {
1530 if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
1531 Constant *Ops[] = { CLHS, CRHS };
1536 // Canonicalize the constant to the RHS.
1542 return Constant::getAllOnesValue(Op0->getType());
1559 return Constant::getAllOnesValue(Op0->getType());
1575 return Constant::getAllOnesValue(Op1->getType());
1580 return Constant::getAllOnesValue(Op0->getType());
1623 if (Constant *CLHS = dyn_cast<Constant>(Op0)) {
1624 if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
1625 Constant *Ops[] = { CLHS, CRHS };
1630 // Canonicalize the constant to the RHS.
1644 return Constant::getNullValue(Op0->getType());
1649 return Constant::getAllOnesValue(Op0->getType());
1731 static Constant *computePointerICmp(const DataLayout *TD,
1767 // Strip off any constant offsets so that we can reason about them.
1773 Constant *LHSOffset = stripAndComputeConstantOffsets(TD, LHS);
1774 Constant *RHSOffset = stripAndComputeConstantOffsets(TD, RHS);
1776 // If LHS and RHS are related via constant offsets to the same base
1811 // address, due to canonicalization and constant folding.
1853 if (Constant *CLHS = dyn_cast<Constant>(LHS)) {
1854 if (Constant *CRHS = dyn_cast<Constant>(RHS))
1857 // If we have a constant, make sure it is on the RHS.
1958 // See if we are doing a comparison with a constant integer.
1967 // Many binary operators with constant RHS have easy to compute constant
2027 if (isa<CastInst>(LHS) && (isa<Constant>(RHS) || isa<CastInst>(RHS))) {
2033 // Turn icmp (ptrtoint x), (ptrtoint/constant) into a compare of the input
2037 if (Constant *RHSC = dyn_cast<Constant>(RHS)) {
2038 // Transfer the cast to the constant.
2066 // Compute the constant that would happen if we truncated to SrcTy then
2068 Constant *Trunc = ConstantExpr::getTrunc(CI, SrcTy);
2069 Constant *RExt = ConstantExpr::getCast(CastInst::ZExt, Trunc, DstTy);
2071 // If the re-extended constant didn't change then this is effectively
2125 // Compute the constant that would happen if we truncated to SrcTy then
2127 Constant *Trunc = ConstantExpr::getTrunc(CI, SrcTy);
2128 Constant *RExt = ConstantExpr::getCast(CastInst::SExt, Trunc, DstTy);
2130 // If the re-extended constant didn't change then this is effectively
2166 Constant::getNullValue(SrcTy),
2175 Constant::getNullValue(SrcTy),
2209 Constant::getNullValue(RHS->getType()),
2216 Constant::getNullValue(LHS->getType()),
2538 if (Constant *C = computePointerICmp(Q.TD, Q.TLI, Pred, LHS, RHS))
2548 // The bases are equal and the indices are constant. Build a constant
2550 // what constant folding can make out of it.
2551 Constant *Null = Constant
2553 Constant *NewLHS = ConstantExpr::getGetElementPtr(Null, IndicesLHS);
2556 Constant *NewRHS = ConstantExpr::getGetElementPtr(Null, IndicesRHS);
2592 if (Constant *CLHS = dyn_cast<Constant>(LHS)) {
2593 if (Constant *CRHS = dyn_cast<Constant>(RHS))
2596 // If we have a constant, make sure it is on the RHS.
2618 // Handle fcmp with constant RHS
2619 if (Constant *RHSC = dyn_cast<Constant>(RHS)) {
2620 // If the constant is a nan, see if we can fold the comparison based on it.
2630 // Check whether the constant is an infinity.
2697 if (isa<Constant>(TrueVal))
2750 // Check to see if this is constant foldable.
2752 if (!isa<Constant>(Ops[i]))
2755 return ConstantExpr::getGetElementPtr(cast<Constant>(Ops[0]), Ops.slice(1));
2769 if (Constant *CAgg = dyn_cast<Constant>(Agg))
2770 if (Constant *CVal = dyn_cast<Constant>(Val))
2837 if (Constant *C = dyn_cast<Constant>(Op))
2888 if (Constant *CLHS = dyn_cast<Constant>(LHS))
2889 if (Constant *CRHS = dyn_cast<Constant>(RHS)) {
2890 Constant *COps[] = {CLHS, CRHS};
2993 SmallVector<Constant *, 4> ConstantArgs;
2996 Constant *C = dyn_cast<Constant>(*I);