diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-07-18 05:26:06 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-07-18 05:26:06 +0000 |
commit | e1b9216bc37d890efe944515d92fe8911f5cb991 (patch) | |
tree | 80001519478968761999aad3105a4fbb41749339 | |
parent | f13b36ddc55705cb00a8ce4aaa804bac2225ace2 (diff) | |
download | bcm5719-llvm-e1b9216bc37d890efe944515d92fe8911f5cb991.tar.gz bcm5719-llvm-e1b9216bc37d890efe944515d92fe8911f5cb991.zip |
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
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineCost.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineCost.cpp b/llvm/lib/Transforms/Utils/InlineCost.cpp index 87aff01a585..5fe85e6ef29 100644 --- a/llvm/lib/Transforms/Utils/InlineCost.cpp +++ b/llvm/lib/Transforms/Utils/InlineCost.cpp @@ -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) { |