[llvm-commits] [llvm] r76285 - /llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
Chris Lattner
clattner at apple.com
Fri Jul 17 22:33:11 PDT 2009
On Jul 17, 2009, at 10:26 PM, Eli Friedman wrote:
> 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.
Hi Eli,
This is a great catch. However, one case that is important to get is
"load <ptr>" where ptr is a (constant) pointer to a constant global.
This can lead to serious shrinkage :)
-Chris
>
>
> 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) {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list