[llvm-commits] [llvm] r76285 - /llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
Eli Friedman
eli.friedman at gmail.com
Fri Jul 17 22:26:23 PDT 2009
Author: efriedma
Date: Sat Jul 18 00:26:06 2009
New Revision: 76285
URL: http://llvm.org/viewvc/llvm-project?rev=76285&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
Modified: llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineCost.cpp?rev=76285&r1=76284&r2=76285&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineCost.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineCost.cpp Sat Jul 18 00:26:06 2009
@@ -42,6 +42,13 @@
// 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) {
More information about the llvm-commits
mailing list