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 | 4612e597790cfed94e967860dd9bc09bd1e338aa (patch) | |
tree | 905e40494a8f478068585314ea2afb663b05d451 | |
parent | ef6ab66bcfdbd87f2e25c720e7e1dca7e36cf269 (diff) | |
download | external_llvm-4612e597790cfed94e967860dd9bc09bd1e338aa.zip external_llvm-4612e597790cfed94e967860dd9bc09bd1e338aa.tar.gz external_llvm-4612e597790cfed94e967860dd9bc09bd1e338aa.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76285 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Utils/InlineCost.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Transforms/Utils/InlineCost.cpp b/lib/Transforms/Utils/InlineCost.cpp index 87aff01..5fe85e6 100644 --- a/lib/Transforms/Utils/InlineCost.cpp +++ b/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) { |