Fix the inline cost calculation to take into account instructions

which cannot be folded even if they have constant operands. Significantly
helps if_spppsubr.c attached to PR4573.

llvm-svn: 76285
This commit is contained in:
Eli Friedman 2009-07-18 05:26:06 +00:00
parent f13b36ddc5
commit e1b9216bc3
1 changed files with 7 additions and 0 deletions

View File

@ -42,6 +42,13 @@ unsigned InlineCostAnalyzer::FunctionInfo::
// Figure out if this instruction will be removed due to simple constant
// propagation.
Instruction &Inst = cast<Instruction>(**UI);
// We can't constant propagate instructions which have effects or
// read memory.
if (Inst.mayReadFromMemory() || Inst.mayHaveSideEffects() ||
isa<AllocationInst>(Inst))
continue;
bool AllOperandsConstant = true;
for (unsigned i = 0, e = Inst.getNumOperands(); i != e; ++i)
if (!isa<Constant>(Inst.getOperand(i)) && Inst.getOperand(i) != V) {