diff options
| author | Bob Wilson <bob.wilson@apple.com> | 2010-01-29 22:39:21 +0000 |
|---|---|---|
| committer | Bob Wilson <bob.wilson@apple.com> | 2010-01-29 22:39:21 +0000 |
| commit | 1b8453067bdc22441010ae5395238a43575cc171 (patch) | |
| tree | 95de7bae23e7db63c784f4e025c36cb22eda6489 /llvm/lib/Transforms | |
| parent | bb4820dc8e079c7276b3cfed5664fe57720e14cf (diff) | |
| download | bcm5719-llvm-1b8453067bdc22441010ae5395238a43575cc171.tar.gz bcm5719-llvm-1b8453067bdc22441010ae5395238a43575cc171.zip | |
Preserve load alignment in instcombine transformations. I've been unable to
create a testcase where this matters. The select+load transformation only
occurs when isSafeToLoadUnconditionally is true, and in those situations,
instcombine also changes the underlying objects to be aligned. This seems
like a good idea regardless, and I've verified that it doesn't pessimize
the subsequent realignment.
llvm-svn: 94850
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp index 306ed6728bc..e58c954e917 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -117,6 +117,7 @@ static Instruction *InstCombineLoadCast(InstCombiner &IC, LoadInst &LI, // the result of the loaded value. Value *NewLoad = IC.Builder->CreateLoad(CastOp, LI.isVolatile(), CI->getName()); + cast<LoadInst>(NewLoad)->setAlignment(LI.getAlignment()); // Now cast the result of the load. return new BitCastInst(NewLoad, LI.getType()); } @@ -205,6 +206,8 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { SI->getOperand(1)->getName()+".val"); Value *V2 = Builder->CreateLoad(SI->getOperand(2), SI->getOperand(2)->getName()+".val"); + cast<LoadInst>(V1)->setAlignment(LI.getAlignment()); + cast<LoadInst>(V2)->setAlignment(LI.getAlignment()); return SelectInst::Create(SI->getCondition(), V1, V2); } |

