diff options
author | Bob Wilson <bob.wilson@apple.com> | 2010-01-30 04:42:39 +0000 |
---|---|---|
committer | Bob Wilson <bob.wilson@apple.com> | 2010-01-30 04:42:39 +0000 |
commit | 49db68fba01722ca032dc5170f8248a9d25f0199 (patch) | |
tree | 575e1422b433c1028bda1df8331249b35730b54d /lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp | |
parent | a6bff982c10f6f19c0a9ba20a6300201449c5f39 (diff) | |
download | llvm-49db68fba01722ca032dc5170f8248a9d25f0199.tar.gz llvm-49db68fba01722ca032dc5170f8248a9d25f0199.tar.bz2 llvm-49db68fba01722ca032dc5170f8248a9d25f0199.tar.xz |
Check alignment of loads when deciding whether it is safe to execute them
unconditionally. Besides checking the offset, also check that the underlying
object is aligned as much as the load itself.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94875 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp index 422ffd03a8..2d13298300 100644 --- a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -200,14 +200,15 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { // if (SelectInst *SI = dyn_cast<SelectInst>(Op)) { // load (select (Cond, &V1, &V2)) --> select(Cond, load &V1, load &V2). - if (isSafeToLoadUnconditionally(SI->getOperand(1), SI, TD) && - isSafeToLoadUnconditionally(SI->getOperand(2), SI, TD)) { + unsigned Align = LI.getAlignment(); + if (isSafeToLoadUnconditionally(SI->getOperand(1), SI, Align, TD) && + isSafeToLoadUnconditionally(SI->getOperand(2), SI, Align, TD)) { LoadInst *V1 = Builder->CreateLoad(SI->getOperand(1), - SI->getOperand(1)->getName()+".val"); + SI->getOperand(1)->getName()+".val"); LoadInst *V2 = Builder->CreateLoad(SI->getOperand(2), - SI->getOperand(2)->getName()+".val"); - V1->setAlignment(LI.getAlignment()); - V2->setAlignment(LI.getAlignment()); + SI->getOperand(2)->getName()+".val"); + V1->setAlignment(Align); + V2->setAlignment(Align); return SelectInst::Create(SI->getCondition(), V1, V2); } |