Instruction *I = dyn_cast<Instruction>(V);
if (!I) return;
- Mask &= V->getType()->getIntegerTypeMask();
+ Mask &= cast<IntegerType>(V->getType())->getBitMask();
switch (I->getOpcode()) {
case Instruction::And:
}
case Instruction::ZExt: {
// Compute the bits in the result that are not present in the input.
- const Type *SrcTy = I->getOperand(0)->getType();
- uint64_t NotIn = ~SrcTy->getIntegerTypeMask();
- uint64_t NewBits = I->getType()->getIntegerTypeMask() & NotIn;
+ const IntegerType *SrcTy = cast<IntegerType>(I->getOperand(0)->getType());
+ uint64_t NotIn = ~SrcTy->getBitMask();
+ uint64_t NewBits = cast<IntegerType>(I->getType())->getBitMask() & NotIn;
- Mask &= SrcTy->getIntegerTypeMask();
+ Mask &= SrcTy->getBitMask();
ComputeMaskedBits(I->getOperand(0), Mask, KnownZero, KnownOne, Depth+1);
assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?");
// The top bits are known to be zero.
}
case Instruction::SExt: {
// Compute the bits in the result that are not present in the input.
- const Type *SrcTy = I->getOperand(0)->getType();
- uint64_t NotIn = ~SrcTy->getIntegerTypeMask();
- uint64_t NewBits = I->getType()->getIntegerTypeMask() & NotIn;
+ const IntegerType *SrcTy = cast<IntegerType>(I->getOperand(0)->getType());
+ uint64_t NotIn = ~SrcTy->getBitMask();
+ uint64_t NewBits = cast<IntegerType>(I->getType())->getBitMask() & NotIn;
- Mask &= SrcTy->getIntegerTypeMask();
+ Mask &= SrcTy->getBitMask();
ComputeMaskedBits(I->getOperand(0), Mask, KnownZero, KnownOne, Depth+1);
assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?");
uint64_t KnownZero,
uint64_t KnownOne,
int64_t &Min, int64_t &Max) {
- uint64_t TypeBits = Ty->getIntegerTypeMask();
+ uint64_t TypeBits = cast<IntegerType>(Ty)->getBitMask();
uint64_t UnknownBits = ~(KnownZero|KnownOne) & TypeBits;
uint64_t SignBit = 1ULL << (Ty->getPrimitiveSizeInBits()-1);
uint64_t KnownOne,
uint64_t &Min,
uint64_t &Max) {
- uint64_t TypeBits = Ty->getIntegerTypeMask();
+ uint64_t TypeBits = cast<IntegerType>(Ty)->getBitMask();
uint64_t UnknownBits = ~(KnownZero|KnownOne) & TypeBits;
// The minimum value is when the unknown bits are all zeros.
}
// If this is the root being simplified, allow it to have multiple uses,
// just set the DemandedMask to all bits.
- DemandedMask = V->getType()->getIntegerTypeMask();
+ DemandedMask = cast<IntegerType>(V->getType())->getBitMask();
} else if (DemandedMask == 0) { // Not demanding any bits from V.
if (V != UndefValue::get(V->getType()))
return UpdateValueUsesWith(V, UndefValue::get(V->getType()));
Instruction *I = dyn_cast<Instruction>(V);
if (!I) return false; // Only analyze instructions.
- DemandedMask &= V->getType()->getIntegerTypeMask();
+ DemandedMask &= cast<IntegerType>(V->getType())->getBitMask();
uint64_t KnownZero2 = 0, KnownOne2 = 0;
switch (I->getOpcode()) {
break;
case Instruction::ZExt: {
// Compute the bits in the result that are not present in the input.
- const Type *SrcTy = I->getOperand(0)->getType();
- uint64_t NotIn = ~SrcTy->getIntegerTypeMask();
- uint64_t NewBits = I->getType()->getIntegerTypeMask() & NotIn;
+ const IntegerType *SrcTy = cast<IntegerType>(I->getOperand(0)->getType());
+ uint64_t NotIn = ~SrcTy->getBitMask();
+ uint64_t NewBits = cast<IntegerType>(I->getType())->getBitMask() & NotIn;
- DemandedMask &= SrcTy->getIntegerTypeMask();
+ DemandedMask &= SrcTy->getBitMask();
if (SimplifyDemandedBits(I->getOperand(0), DemandedMask,
KnownZero, KnownOne, Depth+1))
return true;
}
case Instruction::SExt: {
// Compute the bits in the result that are not present in the input.
- const Type *SrcTy = I->getOperand(0)->getType();
- uint64_t NotIn = ~SrcTy->getIntegerTypeMask();
- uint64_t NewBits = I->getType()->getIntegerTypeMask() & NotIn;
+ const IntegerType *SrcTy = cast<IntegerType>(I->getOperand(0)->getType());
+ uint64_t NotIn = ~SrcTy->getBitMask();
+ uint64_t NewBits = cast<IntegerType>(I->getType())->getBitMask() & NotIn;
// Get the sign bit for the source type
uint64_t InSignBit = 1ULL << (SrcTy->getPrimitiveSizeInBits()-1);
- int64_t InputDemandedBits = DemandedMask & SrcTy->getIntegerTypeMask();
+ int64_t InputDemandedBits = DemandedMask & SrcTy->getBitMask();
// If any of the sign extended bits are demanded, we know that the sign
// bit is demanded.
// Compute the new bits that are at the top now.
uint64_t HighBits = (1ULL << ShiftAmt)-1;
HighBits <<= I->getType()->getPrimitiveSizeInBits() - ShiftAmt;
- uint64_t TypeMask = I->getType()->getIntegerTypeMask();
+ uint64_t TypeMask = cast<IntegerType>(I->getType())->getBitMask();
// Unsigned shift right.
if (SimplifyDemandedBits(I->getOperand(0),
(DemandedMask << ShiftAmt) & TypeMask,
// Compute the new bits that are at the top now.
uint64_t HighBits = (1ULL << ShiftAmt)-1;
HighBits <<= I->getType()->getPrimitiveSizeInBits() - ShiftAmt;
- uint64_t TypeMask = I->getType()->getIntegerTypeMask();
+ uint64_t TypeMask = cast<IntegerType>(I->getType())->getBitMask();
// Signed shift right.
if (SimplifyDemandedBits(I->getOperand(0),
(DemandedMask << ShiftAmt) & TypeMask,
// (X & 254)+1 -> (X&254)|1
uint64_t KnownZero, KnownOne;
if (!isa<PackedType>(I.getType()) &&
- SimplifyDemandedBits(&I, I.getType()->getIntegerTypeMask(),
+ SimplifyDemandedBits(&I, cast<IntegerType>(I.getType())->getBitMask(),
KnownZero, KnownOne))
return &I;
}
// This is a sign extend if the top bits are known zero.
uint64_t Mask = ~0ULL;
Mask <<= 64-(TySizeBits-Size);
- Mask &= XorLHS->getType()->getIntegerTypeMask();
+ Mask &= cast<IntegerType>(XorLHS->getType())->getBitMask();
if (!MaskedValueIsZero(XorLHS, Mask))
Size = 0; // Not a sign ext, but can't be any others either.
goto FoundSExt;
// Form a mask of all bits from the lowest bit added through the top.
uint64_t AddRHSHighBits = ~((AddRHSV & -AddRHSV)-1);
- AddRHSHighBits &= C2->getType()->getIntegerTypeMask();
+ AddRHSHighBits &= C2->getType()->getBitMask();
// See if the and mask includes all of these bits.
uint64_t AddRHSHighBitsAnd = AddRHSHighBits & C2->getZExtValue();
Val >>= 64-TypeBits; // Shift out unwanted 1 bits...
return C->getSExtValue() == Val-1;
}
- return C->getZExtValue() == C->getType()->getIntegerTypeMask()-1;
+ return C->getZExtValue() == C->getType()->getBitMask()-1;
}
// isMinValuePlusOne - return true if this is Min+1
uint64_t AndRHSV = cast<ConstantInt>(AndRHS)->getZExtValue();
// Clear bits that are not part of the constant.
- AndRHSV &= AndRHS->getType()->getIntegerTypeMask();
+ AndRHSV &= AndRHS->getType()->getBitMask();
// If there is only one bit set...
if (isOneBitSet(cast<ConstantInt>(AndRHS))) {
// is all N is, ignore it.
unsigned MB, ME;
if (isRunOfOnes(Mask, MB, ME)) { // begin/end bit of run, inclusive
- uint64_t Mask = RHS->getType()->getIntegerTypeMask();
+ uint64_t Mask = cast<IntegerType>(RHS->getType())->getBitMask();
Mask >>= 64-MB+1;
if (MaskedValueIsZero(RHS, Mask))
break;
// purpose is to compute bits we don't care about.
uint64_t KnownZero, KnownOne;
if (!isa<PackedType>(I.getType())) {
- if (SimplifyDemandedBits(&I, I.getType()->getIntegerTypeMask(),
+ if (SimplifyDemandedBits(&I, cast<IntegerType>(I.getType())->getBitMask(),
KnownZero, KnownOne))
return &I;
} else {
if (ConstantInt *AndRHS = dyn_cast<ConstantInt>(Op1)) {
uint64_t AndRHSMask = AndRHS->getZExtValue();
- uint64_t TypeMask = Op0->getType()->getIntegerTypeMask();
+ uint64_t TypeMask = cast<IntegerType>(Op0->getType())->getBitMask();
uint64_t NotAndRHS = AndRHSMask^TypeMask;
// Optimize a variety of ((val OP C1) & C2) combinations...
// purpose is to compute bits we don't care about.
uint64_t KnownZero, KnownOne;
if (!isa<PackedType>(I.getType()) &&
- SimplifyDemandedBits(&I, I.getType()->getIntegerTypeMask(),
+ SimplifyDemandedBits(&I, cast<IntegerType>(I.getType())->getBitMask(),
KnownZero, KnownOne))
return &I;
// purpose is to compute bits we don't care about.
uint64_t KnownZero, KnownOne;
if (!isa<PackedType>(I.getType()) &&
- SimplifyDemandedBits(&I, I.getType()->getIntegerTypeMask(),
+ SimplifyDemandedBits(&I, cast<IntegerType>(I.getType())->getBitMask(),
KnownZero, KnownOne))
return &I;
// See if we can fold the comparison based on bits known to be zero or one
// in the input.
uint64_t KnownZero, KnownOne;
- if (SimplifyDemandedBits(Op0, Ty->getIntegerTypeMask(),
+ if (SimplifyDemandedBits(Op0, cast<IntegerType>(Ty)->getBitMask(),
KnownZero, KnownOne, 0))
return &I;
// See if we can simplify any instructions used by the instruction whose sole
// purpose is to compute bits we don't care about.
uint64_t KnownZero, KnownOne;
- if (SimplifyDemandedBits(&I, I.getType()->getIntegerTypeMask(),
+ if (SimplifyDemandedBits(&I, cast<IntegerType>(I.getType())->getBitMask(),
KnownZero, KnownOne))
return &I;
// See if we can simplify any instructions used by the LHS whose sole
// purpose is to compute bits we don't care about.
uint64_t KnownZero = 0, KnownOne = 0;
- if (SimplifyDemandedBits(&CI, DestTy->getIntegerTypeMask(),
+ if (SimplifyDemandedBits(&CI, cast<IntegerType>(DestTy)->getBitMask(),
KnownZero, KnownOne))
return &CI;
if (Op1CV == 0 || isPowerOf2_64(Op1CV)) {
// If Op1C some other power of two, convert:
uint64_t KnownZero, KnownOne;
- uint64_t TypeMask = Op1->getType()->getIntegerTypeMask();
+ uint64_t TypeMask = Op1C->getType()->getBitMask();
ComputeMaskedBits(Op0, TypeMask, KnownZero, KnownOne);
// This only works for EQ and NE
// If we're actually extending zero bits and the trunc is a no-op
if (MidSize < DstSize && SrcSize == DstSize) {
// Replace both of the casts with an And of the type mask.
- uint64_t AndValue = CSrc->getType()->getIntegerTypeMask();
+ uint64_t AndValue = cast<IntegerType>(CSrc->getType())->getBitMask();
Constant *AndConst = ConstantInt::get(A->getType(), AndValue);
Instruction *And =
BinaryOperator::createAnd(CSrc->getOperand(0), AndConst);