diff options
author | Chris Lattner <sabre@nondot.org> | 2009-11-02 02:06:37 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-11-02 02:06:37 +0000 |
commit | 7ebbabf5000cad682fcc2e4f58f2f83e1d38ef54 (patch) | |
tree | 958065da5a94d09c7bf190cca72d681100e09195 /lib/Transforms | |
parent | f013eea9727d64c87a73944ce2099c648cb6de6c (diff) |
fix instcombine to only do store sinking when the alignments
of the two loads agree. Propagate that onto the new store.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85772 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 07681d15d8..ba899bf15b 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -11943,9 +11943,11 @@ bool InstCombiner::SimplifyStoreAtEndOfBlock(StoreInst &SI) { return false; --BBI; } - // If this isn't a store, or isn't a store to the same location, bail out. + // If this isn't a store, isn't a store to the same location, or if the + // alignments differ, bail out. OtherStore = dyn_cast<StoreInst>(BBI); - if (!OtherStore || OtherStore->getOperand(1) != SI.getOperand(1)) + if (!OtherStore || OtherStore->getOperand(1) != SI.getOperand(1) || + OtherStore->getAlignment() != SI.getAlignment()) return false; } else { // Otherwise, the other block ended with a conditional branch. If one of the @@ -11960,7 +11962,8 @@ bool InstCombiner::SimplifyStoreAtEndOfBlock(StoreInst &SI) { for (;; --BBI) { // Check to see if we find the matching store. if ((OtherStore = dyn_cast<StoreInst>(BBI))) { - if (OtherStore->getOperand(1) != SI.getOperand(1)) + if (OtherStore->getOperand(1) != SI.getOperand(1) || + OtherStore->getAlignment() != SI.getAlignment()) return false; break; } @@ -11995,7 +11998,8 @@ bool InstCombiner::SimplifyStoreAtEndOfBlock(StoreInst &SI) { // insert it. BBI = DestBB->getFirstNonPHI(); InsertNewInstBefore(new StoreInst(MergedVal, SI.getOperand(1), - OtherStore->isVolatile()), *BBI); + OtherStore->isVolatile(), + SI.getAlignment()), *BBI); // Nuke the old stores. EraseInstFromFunction(SI); |