mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() and
zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method trunc(), to be const and to return a new value instead of modifying the object in place. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121120 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -939,8 +939,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
||||
// If all the high bits are known, we can do this xform.
|
||||
if ((KnownZero|KnownOne).countLeadingOnes() >= SrcBits-DstBits) {
|
||||
// Pull in the high bits from known-ones set.
|
||||
APInt NewRHS(RHS->getValue());
|
||||
NewRHS.zext(SrcBits);
|
||||
APInt NewRHS = RHS->getValue().zext(SrcBits);
|
||||
NewRHS |= KnownOne;
|
||||
return new ICmpInst(ICI.getPredicate(), LHSI->getOperand(0),
|
||||
ConstantInt::get(ICI.getContext(), NewRHS));
|
||||
@@ -1022,10 +1021,8 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
||||
(AndCST->getValue().isNonNegative() && RHSV.isNonNegative()))) {
|
||||
uint32_t BitWidth =
|
||||
cast<IntegerType>(Cast->getOperand(0)->getType())->getBitWidth();
|
||||
APInt NewCST = AndCST->getValue();
|
||||
NewCST.zext(BitWidth);
|
||||
APInt NewCI = RHSV;
|
||||
NewCI.zext(BitWidth);
|
||||
APInt NewCST = AndCST->getValue().zext(BitWidth);
|
||||
APInt NewCI = RHSV.zext(BitWidth);
|
||||
Value *NewAnd =
|
||||
Builder->CreateAnd(Cast->getOperand(0),
|
||||
ConstantInt::get(ICI.getContext(), NewCST),
|
||||
|
@@ -29,11 +29,11 @@ static bool MultiplyOverflows(ConstantInt *C1, ConstantInt *C2, bool sign) {
|
||||
uint32_t W = C1->getBitWidth();
|
||||
APInt LHSExt = C1->getValue(), RHSExt = C2->getValue();
|
||||
if (sign) {
|
||||
LHSExt.sext(W * 2);
|
||||
RHSExt.sext(W * 2);
|
||||
LHSExt = LHSExt.sext(W * 2);
|
||||
RHSExt = RHSExt.sext(W * 2);
|
||||
} else {
|
||||
LHSExt.zext(W * 2);
|
||||
RHSExt.zext(W * 2);
|
||||
LHSExt = LHSExt.zext(W * 2);
|
||||
RHSExt = RHSExt.zext(W * 2);
|
||||
}
|
||||
|
||||
APInt MulExt = LHSExt * RHSExt;
|
||||
|
@@ -34,7 +34,7 @@ static bool ShrinkDemandedConstant(Instruction *I, unsigned OpNo,
|
||||
if (!OpC) return false;
|
||||
|
||||
// If there are no bits set that aren't demanded, nothing to do.
|
||||
Demanded.zextOrTrunc(OpC->getValue().getBitWidth());
|
||||
Demanded = Demanded.zextOrTrunc(OpC->getValue().getBitWidth());
|
||||
if ((~Demanded & OpC->getValue()) == 0)
|
||||
return false;
|
||||
|
||||
@@ -388,15 +388,15 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
|
||||
break;
|
||||
case Instruction::Trunc: {
|
||||
unsigned truncBf = I->getOperand(0)->getType()->getScalarSizeInBits();
|
||||
DemandedMask.zext(truncBf);
|
||||
KnownZero.zext(truncBf);
|
||||
KnownOne.zext(truncBf);
|
||||
DemandedMask = DemandedMask.zext(truncBf);
|
||||
KnownZero = KnownZero.zext(truncBf);
|
||||
KnownOne = KnownOne.zext(truncBf);
|
||||
if (SimplifyDemandedBits(I->getOperandUse(0), DemandedMask,
|
||||
KnownZero, KnownOne, Depth+1))
|
||||
return I;
|
||||
DemandedMask.trunc(BitWidth);
|
||||
KnownZero.trunc(BitWidth);
|
||||
KnownOne.trunc(BitWidth);
|
||||
DemandedMask = DemandedMask.trunc(BitWidth);
|
||||
KnownZero = KnownZero.trunc(BitWidth);
|
||||
KnownOne = KnownOne.trunc(BitWidth);
|
||||
assert(!(KnownZero & KnownOne) && "Bits known to be one AND zero?");
|
||||
break;
|
||||
}
|
||||
@@ -426,15 +426,15 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
|
||||
// Compute the bits in the result that are not present in the input.
|
||||
unsigned SrcBitWidth =I->getOperand(0)->getType()->getScalarSizeInBits();
|
||||
|
||||
DemandedMask.trunc(SrcBitWidth);
|
||||
KnownZero.trunc(SrcBitWidth);
|
||||
KnownOne.trunc(SrcBitWidth);
|
||||
DemandedMask = DemandedMask.trunc(SrcBitWidth);
|
||||
KnownZero = KnownZero.trunc(SrcBitWidth);
|
||||
KnownOne = KnownOne.trunc(SrcBitWidth);
|
||||
if (SimplifyDemandedBits(I->getOperandUse(0), DemandedMask,
|
||||
KnownZero, KnownOne, Depth+1))
|
||||
return I;
|
||||
DemandedMask.zext(BitWidth);
|
||||
KnownZero.zext(BitWidth);
|
||||
KnownOne.zext(BitWidth);
|
||||
DemandedMask = DemandedMask.zext(BitWidth);
|
||||
KnownZero = KnownZero.zext(BitWidth);
|
||||
KnownOne = KnownOne.zext(BitWidth);
|
||||
assert(!(KnownZero & KnownOne) && "Bits known to be one AND zero?");
|
||||
// The top bits are known to be zero.
|
||||
KnownZero |= APInt::getHighBitsSet(BitWidth, BitWidth - SrcBitWidth);
|
||||
@@ -453,15 +453,15 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
|
||||
if ((NewBits & DemandedMask) != 0)
|
||||
InputDemandedBits.setBit(SrcBitWidth-1);
|
||||
|
||||
InputDemandedBits.trunc(SrcBitWidth);
|
||||
KnownZero.trunc(SrcBitWidth);
|
||||
KnownOne.trunc(SrcBitWidth);
|
||||
InputDemandedBits = InputDemandedBits.trunc(SrcBitWidth);
|
||||
KnownZero = KnownZero.trunc(SrcBitWidth);
|
||||
KnownOne = KnownOne.trunc(SrcBitWidth);
|
||||
if (SimplifyDemandedBits(I->getOperandUse(0), InputDemandedBits,
|
||||
KnownZero, KnownOne, Depth+1))
|
||||
return I;
|
||||
InputDemandedBits.zext(BitWidth);
|
||||
KnownZero.zext(BitWidth);
|
||||
KnownOne.zext(BitWidth);
|
||||
InputDemandedBits = InputDemandedBits.zext(BitWidth);
|
||||
KnownZero = KnownZero.zext(BitWidth);
|
||||
KnownOne = KnownOne.zext(BitWidth);
|
||||
assert(!(KnownZero & KnownOne) && "Bits known to be one AND zero?");
|
||||
|
||||
// If the sign bit of the input is known set or clear, then we know the
|
||||
|
Reference in New Issue
Block a user