mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-19 20:34:38 +00:00
the NumCastsRemoved argument to CanEvaluateSExtd is dead, remove it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93110 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dde5ee5d37
commit
6954ceec1a
@ -783,8 +783,7 @@ Instruction *InstCombiner::visitZExt(ZExtInst &CI) {
|
|||||||
/// This function works on both vectors and scalars. For vectors, the result is
|
/// This function works on both vectors and scalars. For vectors, the result is
|
||||||
/// the number of bits known sign extended in each element.
|
/// the number of bits known sign extended in each element.
|
||||||
///
|
///
|
||||||
static unsigned CanEvaluateSExtd(Value *V, const Type *Ty,
|
static unsigned CanEvaluateSExtd(Value *V, const Type *Ty, TargetData *TD) {
|
||||||
unsigned &NumCastsRemoved, TargetData *TD) {
|
|
||||||
assert(V->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits() &&
|
assert(V->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits() &&
|
||||||
"Can't sign extend type to a smaller type");
|
"Can't sign extend type to a smaller type");
|
||||||
// If this is a constant, return the number of sign bits the extended version
|
// If this is a constant, return the number of sign bits the extended version
|
||||||
@ -795,16 +794,9 @@ static unsigned CanEvaluateSExtd(Value *V, const Type *Ty,
|
|||||||
Instruction *I = dyn_cast<Instruction>(V);
|
Instruction *I = dyn_cast<Instruction>(V);
|
||||||
if (!I) return 0;
|
if (!I) return 0;
|
||||||
|
|
||||||
// If this is a truncate from the destination type, we can trivially eliminate
|
// If this is a truncate from the dest type, we can trivially eliminate it.
|
||||||
// it, and this will remove a cast overall.
|
if (isa<TruncInst>(I) && I->getOperand(0)->getType() == Ty)
|
||||||
if (isa<TruncInst>(I) && I->getOperand(0)->getType() == Ty) {
|
|
||||||
// If the operand of the truncate is itself a cast, and is eliminable, do
|
|
||||||
// not count this as an eliminable cast. We would prefer to eliminate those
|
|
||||||
// two casts first.
|
|
||||||
if (!isa<CastInst>(I->getOperand(0)) && I->hasOneUse())
|
|
||||||
++NumCastsRemoved;
|
|
||||||
return ComputeNumSignBits(I->getOperand(0), TD);
|
return ComputeNumSignBits(I->getOperand(0), TD);
|
||||||
}
|
|
||||||
|
|
||||||
// We can't extend or shrink something that has multiple uses: doing so would
|
// We can't extend or shrink something that has multiple uses: doing so would
|
||||||
// require duplicating the instruction in general, which isn't profitable.
|
// require duplicating the instruction in general, which isn't profitable.
|
||||||
@ -819,23 +811,23 @@ static unsigned CanEvaluateSExtd(Value *V, const Type *Ty,
|
|||||||
case Instruction::Or:
|
case Instruction::Or:
|
||||||
case Instruction::Xor:
|
case Instruction::Xor:
|
||||||
// These operators can all arbitrarily be extended or truncated.
|
// These operators can all arbitrarily be extended or truncated.
|
||||||
Tmp1 = CanEvaluateSExtd(I->getOperand(0), Ty, NumCastsRemoved, TD);
|
Tmp1 = CanEvaluateSExtd(I->getOperand(0), Ty, TD);
|
||||||
if (Tmp1 == 0) return 0;
|
if (Tmp1 == 0) return 0;
|
||||||
Tmp2 = CanEvaluateSExtd(I->getOperand(1), Ty, NumCastsRemoved, TD);
|
Tmp2 = CanEvaluateSExtd(I->getOperand(1), Ty, TD);
|
||||||
return std::min(Tmp1, Tmp2);
|
return std::min(Tmp1, Tmp2);
|
||||||
case Instruction::Add:
|
case Instruction::Add:
|
||||||
case Instruction::Sub:
|
case Instruction::Sub:
|
||||||
// Add/Sub can have at most one carry/borrow bit.
|
// Add/Sub can have at most one carry/borrow bit.
|
||||||
Tmp1 = CanEvaluateSExtd(I->getOperand(0), Ty, NumCastsRemoved, TD);
|
Tmp1 = CanEvaluateSExtd(I->getOperand(0), Ty, TD);
|
||||||
if (Tmp1 == 0) return 0;
|
if (Tmp1 == 0) return 0;
|
||||||
Tmp2 = CanEvaluateSExtd(I->getOperand(1), Ty, NumCastsRemoved, TD);
|
Tmp2 = CanEvaluateSExtd(I->getOperand(1), Ty, TD);
|
||||||
if (Tmp2 == 0) return 0;
|
if (Tmp2 == 0) return 0;
|
||||||
return std::min(Tmp1, Tmp2)-1;
|
return std::min(Tmp1, Tmp2)-1;
|
||||||
case Instruction::Mul:
|
case Instruction::Mul:
|
||||||
// These operators can all arbitrarily be extended or truncated.
|
// These operators can all arbitrarily be extended or truncated.
|
||||||
if (!CanEvaluateSExtd(I->getOperand(0), Ty, NumCastsRemoved, TD))
|
if (!CanEvaluateSExtd(I->getOperand(0), Ty, TD))
|
||||||
return 0;
|
return 0;
|
||||||
if (!CanEvaluateSExtd(I->getOperand(1), Ty, NumCastsRemoved, TD))
|
if (!CanEvaluateSExtd(I->getOperand(1), Ty, TD))
|
||||||
return 0;
|
return 0;
|
||||||
return 1; // IMPROVE?
|
return 1; // IMPROVE?
|
||||||
|
|
||||||
@ -856,9 +848,9 @@ static unsigned CanEvaluateSExtd(Value *V, const Type *Ty,
|
|||||||
}
|
}
|
||||||
case Instruction::Select: {
|
case Instruction::Select: {
|
||||||
SelectInst *SI = cast<SelectInst>(I);
|
SelectInst *SI = cast<SelectInst>(I);
|
||||||
Tmp1 = CanEvaluateSExtd(SI->getTrueValue(), Ty, NumCastsRemoved, TD);
|
Tmp1 = CanEvaluateSExtd(SI->getTrueValue(), Ty, TD);
|
||||||
if (Tmp1 == 0) return 0;
|
if (Tmp1 == 0) return 0;
|
||||||
Tmp2 = CanEvaluateSExtd(SI->getFalseValue(), Ty, NumCastsRemoved,TD);
|
Tmp2 = CanEvaluateSExtd(SI->getFalseValue(), Ty, TD);
|
||||||
return std::min(Tmp1, Tmp2);
|
return std::min(Tmp1, Tmp2);
|
||||||
}
|
}
|
||||||
case Instruction::PHI: {
|
case Instruction::PHI: {
|
||||||
@ -869,8 +861,7 @@ static unsigned CanEvaluateSExtd(Value *V, const Type *Ty,
|
|||||||
unsigned Result = ~0U;
|
unsigned Result = ~0U;
|
||||||
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
|
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
|
||||||
Result = std::min(Result,
|
Result = std::min(Result,
|
||||||
CanEvaluateSExtd(PN->getIncomingValue(i), Ty,
|
CanEvaluateSExtd(PN->getIncomingValue(i), Ty, TD));
|
||||||
NumCastsRemoved, TD));
|
|
||||||
if (Result == 0) return 0;
|
if (Result == 0) return 0;
|
||||||
}
|
}
|
||||||
return Result;
|
return Result;
|
||||||
@ -911,11 +902,7 @@ Instruction *InstCombiner::visitSExt(SExtInst &CI) {
|
|||||||
// expression tree to something weird like i93 unless the source is also
|
// expression tree to something weird like i93 unless the source is also
|
||||||
// strange.
|
// strange.
|
||||||
if (isa<VectorType>(DestTy) || ShouldChangeType(SrcTy, DestTy)) {
|
if (isa<VectorType>(DestTy) || ShouldChangeType(SrcTy, DestTy)) {
|
||||||
unsigned NumCastsRemoved = 0;
|
unsigned NumBitsSExt = CanEvaluateSExtd(Src, DestTy, TD);
|
||||||
// Check to see if we can do this transformation, and if so, how many bits
|
|
||||||
// of the promoted expression will be known copies of the sign bit in the
|
|
||||||
// result.
|
|
||||||
unsigned NumBitsSExt = CanEvaluateSExtd(Src, DestTy, NumCastsRemoved, TD);
|
|
||||||
if (NumBitsSExt == 0)
|
if (NumBitsSExt == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user