mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-02 22:23:10 +00:00
Rename ComputeMaskedBits to computeKnownBits. "Masked" has been
inappropriate since it lost its Mask parameter in r154011. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208811 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -313,9 +313,9 @@ public:
|
||||
return nullptr; // Don't do anything with FI
|
||||
}
|
||||
|
||||
void ComputeMaskedBits(Value *V, APInt &KnownZero, APInt &KnownOne,
|
||||
unsigned Depth = 0) const {
|
||||
return llvm::ComputeMaskedBits(V, KnownZero, KnownOne, DL, Depth);
|
||||
void computeKnownBits(Value *V, APInt &KnownZero, APInt &KnownOne,
|
||||
unsigned Depth = 0) const {
|
||||
return llvm::computeKnownBits(V, KnownZero, KnownOne, DL, Depth);
|
||||
}
|
||||
|
||||
bool MaskedValueIsZero(Value *V, const APInt &Mask,
|
||||
|
||||
@@ -979,7 +979,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
||||
IntegerType *IT = cast<IntegerType>(I.getType());
|
||||
APInt LHSKnownOne(IT->getBitWidth(), 0);
|
||||
APInt LHSKnownZero(IT->getBitWidth(), 0);
|
||||
ComputeMaskedBits(XorLHS, LHSKnownZero, LHSKnownOne);
|
||||
computeKnownBits(XorLHS, LHSKnownZero, LHSKnownOne);
|
||||
if ((XorRHS->getValue() | LHSKnownZero).isAllOnesValue())
|
||||
return BinaryOperator::CreateSub(ConstantExpr::getAdd(XorRHS, CI),
|
||||
XorLHS);
|
||||
@@ -1047,11 +1047,11 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
||||
if (IntegerType *IT = dyn_cast<IntegerType>(I.getType())) {
|
||||
APInt LHSKnownOne(IT->getBitWidth(), 0);
|
||||
APInt LHSKnownZero(IT->getBitWidth(), 0);
|
||||
ComputeMaskedBits(LHS, LHSKnownZero, LHSKnownOne);
|
||||
computeKnownBits(LHS, LHSKnownZero, LHSKnownOne);
|
||||
if (LHSKnownZero != 0) {
|
||||
APInt RHSKnownOne(IT->getBitWidth(), 0);
|
||||
APInt RHSKnownZero(IT->getBitWidth(), 0);
|
||||
ComputeMaskedBits(RHS, RHSKnownZero, RHSKnownOne);
|
||||
computeKnownBits(RHS, RHSKnownZero, RHSKnownOne);
|
||||
|
||||
// No bits in common -> bitwise or.
|
||||
if ((LHSKnownZero|RHSKnownZero).isAllOnesValue())
|
||||
|
||||
@@ -322,7 +322,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
|
||||
uint32_t BitWidth = IT->getBitWidth();
|
||||
APInt KnownZero(BitWidth, 0);
|
||||
APInt KnownOne(BitWidth, 0);
|
||||
ComputeMaskedBits(II->getArgOperand(0), KnownZero, KnownOne);
|
||||
computeKnownBits(II->getArgOperand(0), KnownZero, KnownOne);
|
||||
unsigned TrailingZeros = KnownOne.countTrailingZeros();
|
||||
APInt Mask(APInt::getLowBitsSet(BitWidth, TrailingZeros));
|
||||
if ((Mask & KnownZero) == Mask)
|
||||
@@ -340,7 +340,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
|
||||
uint32_t BitWidth = IT->getBitWidth();
|
||||
APInt KnownZero(BitWidth, 0);
|
||||
APInt KnownOne(BitWidth, 0);
|
||||
ComputeMaskedBits(II->getArgOperand(0), KnownZero, KnownOne);
|
||||
computeKnownBits(II->getArgOperand(0), KnownZero, KnownOne);
|
||||
unsigned LeadingZeros = KnownOne.countLeadingZeros();
|
||||
APInt Mask(APInt::getHighBitsSet(BitWidth, LeadingZeros));
|
||||
if ((Mask & KnownZero) == Mask)
|
||||
@@ -355,14 +355,14 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
|
||||
uint32_t BitWidth = IT->getBitWidth();
|
||||
APInt LHSKnownZero(BitWidth, 0);
|
||||
APInt LHSKnownOne(BitWidth, 0);
|
||||
ComputeMaskedBits(LHS, LHSKnownZero, LHSKnownOne);
|
||||
computeKnownBits(LHS, LHSKnownZero, LHSKnownOne);
|
||||
bool LHSKnownNegative = LHSKnownOne[BitWidth - 1];
|
||||
bool LHSKnownPositive = LHSKnownZero[BitWidth - 1];
|
||||
|
||||
if (LHSKnownNegative || LHSKnownPositive) {
|
||||
APInt RHSKnownZero(BitWidth, 0);
|
||||
APInt RHSKnownOne(BitWidth, 0);
|
||||
ComputeMaskedBits(RHS, RHSKnownZero, RHSKnownOne);
|
||||
computeKnownBits(RHS, RHSKnownZero, RHSKnownOne);
|
||||
bool RHSKnownNegative = RHSKnownOne[BitWidth - 1];
|
||||
bool RHSKnownPositive = RHSKnownZero[BitWidth - 1];
|
||||
if (LHSKnownNegative && RHSKnownNegative) {
|
||||
@@ -449,10 +449,10 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
|
||||
|
||||
APInt LHSKnownZero(BitWidth, 0);
|
||||
APInt LHSKnownOne(BitWidth, 0);
|
||||
ComputeMaskedBits(LHS, LHSKnownZero, LHSKnownOne);
|
||||
computeKnownBits(LHS, LHSKnownZero, LHSKnownOne);
|
||||
APInt RHSKnownZero(BitWidth, 0);
|
||||
APInt RHSKnownOne(BitWidth, 0);
|
||||
ComputeMaskedBits(RHS, RHSKnownZero, RHSKnownOne);
|
||||
computeKnownBits(RHS, RHSKnownZero, RHSKnownOne);
|
||||
|
||||
// Get the largest possible values for each operand.
|
||||
APInt LHSMax = ~LHSKnownZero;
|
||||
|
||||
@@ -553,7 +553,7 @@ Instruction *InstCombiner::transformZExtICmp(ICmpInst *ICI, Instruction &CI,
|
||||
// If Op1C some other power of two, convert:
|
||||
uint32_t BitWidth = Op1C->getType()->getBitWidth();
|
||||
APInt KnownZero(BitWidth, 0), KnownOne(BitWidth, 0);
|
||||
ComputeMaskedBits(ICI->getOperand(0), KnownZero, KnownOne);
|
||||
computeKnownBits(ICI->getOperand(0), KnownZero, KnownOne);
|
||||
|
||||
APInt KnownZeroMask(~KnownZero);
|
||||
if (KnownZeroMask.isPowerOf2()) { // Exactly 1 possible 1?
|
||||
@@ -601,8 +601,8 @@ Instruction *InstCombiner::transformZExtICmp(ICmpInst *ICI, Instruction &CI,
|
||||
|
||||
APInt KnownZeroLHS(BitWidth, 0), KnownOneLHS(BitWidth, 0);
|
||||
APInt KnownZeroRHS(BitWidth, 0), KnownOneRHS(BitWidth, 0);
|
||||
ComputeMaskedBits(LHS, KnownZeroLHS, KnownOneLHS);
|
||||
ComputeMaskedBits(RHS, KnownZeroRHS, KnownOneRHS);
|
||||
computeKnownBits(LHS, KnownZeroLHS, KnownOneLHS);
|
||||
computeKnownBits(RHS, KnownZeroRHS, KnownOneRHS);
|
||||
|
||||
if (KnownZeroLHS == KnownZeroRHS && KnownOneLHS == KnownOneRHS) {
|
||||
APInt KnownBits = KnownZeroLHS | KnownOneLHS;
|
||||
@@ -921,7 +921,7 @@ Instruction *InstCombiner::transformSExtICmp(ICmpInst *ICI, Instruction &CI) {
|
||||
ICI->isEquality() && (Op1C->isZero() || Op1C->getValue().isPowerOf2())){
|
||||
unsigned BitWidth = Op1C->getType()->getBitWidth();
|
||||
APInt KnownZero(BitWidth, 0), KnownOne(BitWidth, 0);
|
||||
ComputeMaskedBits(Op0, KnownZero, KnownOne);
|
||||
computeKnownBits(Op0, KnownZero, KnownOne);
|
||||
|
||||
APInt KnownZeroMask(~KnownZero);
|
||||
if (KnownZeroMask.isPowerOf2()) {
|
||||
|
||||
@@ -1058,7 +1058,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
||||
unsigned DstBits = LHSI->getType()->getPrimitiveSizeInBits(),
|
||||
SrcBits = LHSI->getOperand(0)->getType()->getPrimitiveSizeInBits();
|
||||
APInt KnownZero(SrcBits, 0), KnownOne(SrcBits, 0);
|
||||
ComputeMaskedBits(LHSI->getOperand(0), KnownZero, KnownOne);
|
||||
computeKnownBits(LHSI->getOperand(0), KnownZero, KnownOne);
|
||||
|
||||
// If all the high bits are known, we can do this xform.
|
||||
if ((KnownZero|KnownOne).countLeadingOnes() >= SrcBits-DstBits) {
|
||||
|
||||
@@ -144,7 +144,7 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
|
||||
|
||||
Instruction *I = dyn_cast<Instruction>(V);
|
||||
if (!I) {
|
||||
ComputeMaskedBits(V, KnownZero, KnownOne, Depth);
|
||||
computeKnownBits(V, KnownZero, KnownOne, Depth);
|
||||
return nullptr; // Only analyze instructions.
|
||||
}
|
||||
|
||||
@@ -158,8 +158,8 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
|
||||
// this instruction has a simpler value in that context.
|
||||
if (I->getOpcode() == Instruction::And) {
|
||||
// If either the LHS or the RHS are Zero, the result is zero.
|
||||
ComputeMaskedBits(I->getOperand(1), RHSKnownZero, RHSKnownOne, Depth+1);
|
||||
ComputeMaskedBits(I->getOperand(0), LHSKnownZero, LHSKnownOne, Depth+1);
|
||||
computeKnownBits(I->getOperand(1), RHSKnownZero, RHSKnownOne, Depth+1);
|
||||
computeKnownBits(I->getOperand(0), LHSKnownZero, LHSKnownOne, Depth+1);
|
||||
|
||||
// If all of the demanded bits are known 1 on one side, return the other.
|
||||
// These bits cannot contribute to the result of the 'and' in this
|
||||
@@ -180,8 +180,8 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
|
||||
// only bits from X or Y are demanded.
|
||||
|
||||
// If either the LHS or the RHS are One, the result is One.
|
||||
ComputeMaskedBits(I->getOperand(1), RHSKnownZero, RHSKnownOne, Depth+1);
|
||||
ComputeMaskedBits(I->getOperand(0), LHSKnownZero, LHSKnownOne, Depth+1);
|
||||
computeKnownBits(I->getOperand(1), RHSKnownZero, RHSKnownOne, Depth+1);
|
||||
computeKnownBits(I->getOperand(0), LHSKnownZero, LHSKnownOne, Depth+1);
|
||||
|
||||
// If all of the demanded bits are known zero on one side, return the
|
||||
// other. These bits cannot contribute to the result of the 'or' in this
|
||||
@@ -205,8 +205,8 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
|
||||
// We can simplify (X^Y) -> X or Y in the user's context if we know that
|
||||
// only bits from X or Y are demanded.
|
||||
|
||||
ComputeMaskedBits(I->getOperand(1), RHSKnownZero, RHSKnownOne, Depth+1);
|
||||
ComputeMaskedBits(I->getOperand(0), LHSKnownZero, LHSKnownOne, Depth+1);
|
||||
computeKnownBits(I->getOperand(1), RHSKnownZero, RHSKnownOne, Depth+1);
|
||||
computeKnownBits(I->getOperand(0), LHSKnownZero, LHSKnownOne, Depth+1);
|
||||
|
||||
// If all of the demanded bits are known zero on one side, return the
|
||||
// other.
|
||||
@@ -217,7 +217,7 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
|
||||
}
|
||||
|
||||
// Compute the KnownZero/KnownOne bits to simplify things downstream.
|
||||
ComputeMaskedBits(I, KnownZero, KnownOne, Depth);
|
||||
computeKnownBits(I, KnownZero, KnownOne, Depth);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
|
||||
|
||||
switch (I->getOpcode()) {
|
||||
default:
|
||||
ComputeMaskedBits(I, KnownZero, KnownOne, Depth);
|
||||
computeKnownBits(I, KnownZero, KnownOne, Depth);
|
||||
break;
|
||||
case Instruction::And:
|
||||
// If either the LHS or the RHS are Zero, the result is zero.
|
||||
@@ -579,9 +579,9 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
|
||||
return I;
|
||||
}
|
||||
|
||||
// Otherwise just hand the sub off to ComputeMaskedBits to fill in
|
||||
// Otherwise just hand the sub off to computeKnownBits to fill in
|
||||
// the known zeros and ones.
|
||||
ComputeMaskedBits(V, KnownZero, KnownOne, Depth);
|
||||
computeKnownBits(V, KnownZero, KnownOne, Depth);
|
||||
|
||||
// Turn this into a xor if LHS is 2^n-1 and the remaining bits are known
|
||||
// zero.
|
||||
@@ -752,7 +752,7 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
|
||||
// remainder is zero.
|
||||
if (DemandedMask.isNegative() && KnownZero.isNonNegative()) {
|
||||
APInt LHSKnownZero(BitWidth, 0), LHSKnownOne(BitWidth, 0);
|
||||
ComputeMaskedBits(I->getOperand(0), LHSKnownZero, LHSKnownOne, Depth+1);
|
||||
computeKnownBits(I->getOperand(0), LHSKnownZero, LHSKnownOne, Depth+1);
|
||||
// If it's known zero, our sign bit is also zero.
|
||||
if (LHSKnownZero.isNegative())
|
||||
KnownZero.setBit(KnownZero.getBitWidth() - 1);
|
||||
@@ -814,7 +814,7 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
ComputeMaskedBits(V, KnownZero, KnownOne, Depth);
|
||||
computeKnownBits(V, KnownZero, KnownOne, Depth);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user