summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-07-25 02:21:23 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-07-25 02:21:23 +0000
commit4728569d0a8c255f9727409879bbd290c0953d83 (patch)
tree00426f85a46c0c50875e91ced247634e4b3f8ba1 /llvm/lib/Transforms
parent6f014d37d5c57e42d55dc95fcd992561439e4aad (diff)
downloadbcm5719-llvm-4728569d0a8c255f9727409879bbd290c0953d83.tar.gz
bcm5719-llvm-4728569d0a8c255f9727409879bbd290c0953d83.zip
[GVNHoist] Properly merge alignments when hoisting
If we two loads of two different alignments, we must use the minimum of the two alignments when hoisting. Same deal for stores. For allocas, use the maximum of the two allocas. llvm-svn: 276601
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/GVNHoist.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVNHoist.cpp b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
index e7179a342c2..0b5e94f8fb9 100644
--- a/llvm/lib/Transforms/Scalar/GVNHoist.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
@@ -628,7 +628,6 @@ public:
cast<Instruction>(cast<StoreInst>(OtherInst)->getValueOperand());
ClonedVal->intersectOptionalDataWith(OtherVal);
}
- ClonedVal->clearSubclassOptionalData();
Repl->replaceUsesOfWith(Val, ClonedVal);
}
@@ -685,12 +684,23 @@ public:
for (Instruction *I : InstructionsToHoist)
if (I != Repl) {
++NR;
- if (isa<LoadInst>(Repl))
+ if (auto *ReplacementLoad = dyn_cast<LoadInst>(Repl)) {
+ ReplacementLoad->setAlignment(
+ std::min(ReplacementLoad->getAlignment(),
+ cast<LoadInst>(I)->getAlignment()));
++NumLoadsRemoved;
- else if (isa<StoreInst>(Repl))
+ } else if (auto *ReplacementStore = dyn_cast<StoreInst>(Repl)) {
+ ReplacementStore->setAlignment(
+ std::min(ReplacementStore->getAlignment(),
+ cast<StoreInst>(I)->getAlignment()));
++NumStoresRemoved;
- else if (isa<CallInst>(Repl))
+ } else if (auto *ReplacementAlloca = dyn_cast<AllocaInst>(Repl)) {
+ ReplacementAlloca->setAlignment(
+ std::max(ReplacementAlloca->getAlignment(),
+ cast<AllocaInst>(I)->getAlignment()));
+ } else if (isa<CallInst>(Repl)) {
++NumCallsRemoved;
+ }
Repl->intersectOptionalDataWith(I);
I->replaceAllUsesWith(Repl);
I->eraseFromParent();
OpenPOWER on IntegriCloud