[LLVMdev] DeadStoreElimination: do better without TargetData
Chris Lattner
clattner at apple.com
Wed Nov 4 08:32:40 PST 2009
On Nov 4, 2009, at 7:21 AM, Hans Wennborg wrote:
> Re-posting with better-looking code.
Thanks, do you have a testcase showing what this does?
-Chris
>
> Hans Wennborg wrote:
>> The attached patch makes DeadStoreElimination able to remove stores
>> in store-store dependencies when the operand types are equal, even
>> if there is no TargetData available.
>> / Hans
>> ------------------------------------------------------------------------
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> Index: lib/Transforms/Scalar/DeadStoreElimination.cpp
> ===================================================================
> --- lib/Transforms/Scalar/DeadStoreElimination.cpp (revision 86023)
> +++ lib/Transforms/Scalar/DeadStoreElimination.cpp (working copy)
> @@ -117,10 +117,12 @@
>
> // If this is a store-store dependence, then the previous store
> is dead so
> // long as this store is at least as big as it.
> - if (StoreInst *DepStore = dyn_cast<StoreInst>(InstDep.getInst()))
> - if (TD &&
> - TD->getTypeStoreSize(DepStore->getOperand(0)->getType()) <=
> - TD->getTypeStoreSize(SI->getOperand(0)->getType())) {
> + if (StoreInst *DepStore = dyn_cast<StoreInst>(InstDep.getInst
> ())) {
> + const Type *DepType = DepStore->getOperand(0)->getType();
> + const Type *SIType = SI->getOperand(0)->getType();
> + if (DepType == SIType ||
> + (TD &&
> + TD->getTypeStoreSize(DepType) <= TD->getTypeStoreSize
> (SIType))) {
> // Delete the store and now-dead instructions that feed it.
> DeleteDeadInstruction(DepStore);
> NumFastStores++;
> @@ -133,6 +135,7 @@
> --BBI;
> continue;
> }
> + }
>
> // If we're storing the same value back to a pointer that we just
> // loaded from, then the store can be removed.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list