Disable folding sext(trunc(x)) -> x (and other similar cast/cast cases) when the

trunc has multiple uses.  Codegen is not able to coalesce the subreg case 
correctly and so this leads to higher register pressure and spilling (see PR5997).

This speeds up 256.bzip2 from 8.60 -> 8.04s on my machine, ~7%.

llvm-svn: 93200
This commit is contained in:
Chris Lattner 2010-01-11 22:45:25 +00:00
parent 88f3eb898a
commit a6b1356cf9
1 changed files with 14 additions and 6 deletions

View File

@ -325,8 +325,11 @@ static bool CanEvaluateTruncated(Value *V, const Type *Ty) {
const Type *OrigTy = V->getType(); const Type *OrigTy = V->getType();
// If this is an extension from the dest type, we can eliminate it. // If this is an extension from the dest type, we can eliminate it, even if it
if ((isa<ZExtInst>(I) || isa<SExtInst>(I)) && // has multiple uses.
// FIXME: This is currently disabled until codegen can handle this without
// pessimizing code, PR5997.
if (0 && (isa<ZExtInst>(I) || isa<SExtInst>(I)) &&
I->getOperand(0)->getType() == Ty) I->getOperand(0)->getType() == Ty)
return true; return true;
@ -606,8 +609,10 @@ static bool CanEvaluateZExtd(Value *V, const Type *Ty, unsigned &BitsToClear) {
if (!I) return false; if (!I) return false;
// If the input is a truncate from the destination type, we can trivially // If the input is a truncate from the destination type, we can trivially
// eliminate it. // eliminate it, even if it has multiple uses.
if (isa<TruncInst>(I) && I->getOperand(0)->getType() == Ty) // FIXME: This is currently disabled until codegen can handle this without
// pessimizing code, PR5997.
if (0 && isa<TruncInst>(I) && I->getOperand(0)->getType() == Ty)
return true; return true;
// 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
@ -853,8 +858,11 @@ static bool CanEvaluateSExtd(Value *V, const Type *Ty) {
Instruction *I = dyn_cast<Instruction>(V); Instruction *I = dyn_cast<Instruction>(V);
if (!I) return false; if (!I) return false;
// If this is a truncate from the dest type, we can trivially eliminate it. // If this is a truncate from the dest type, we can trivially eliminate it,
if (isa<TruncInst>(I) && I->getOperand(0)->getType() == Ty) // even if it has multiple uses.
// FIXME: This is currently disabled until codegen can handle this without
// pessimizing code, PR5997.
if (0 && isa<TruncInst>(I) && I->getOperand(0)->getType() == Ty)
return true; return true;
// 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