aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2010-01-30 04:42:39 +0000
committerBob Wilson <bob.wilson@apple.com>2010-01-30 04:42:39 +0000
commit798d3f79cdc0ce091da57662b99effadc103cd80 (patch)
tree575e1422b433c1028bda1df8331249b35730b54d /lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
parent73e1dbe59a3f02390b1b0112bce2b8c6fe847e89 (diff)
downloadexternal_llvm-798d3f79cdc0ce091da57662b99effadc103cd80.tar.gz
external_llvm-798d3f79cdc0ce091da57662b99effadc103cd80.tar.bz2
external_llvm-798d3f79cdc0ce091da57662b99effadc103cd80.zip
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.cpp13
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);
}