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 | a2440259c7bc10102f92e318329d1d101107862d (patch) | |
| tree | 497cb3e687edfea086c435e2972114032f027942 | |
| parent | f28da1511c0d244eb81b1fa6a91cc2371435d886 (diff) | |
| download | external_llvm-a2440259c7bc10102f92e318329d1d101107862d.zip external_llvm-a2440259c7bc10102f92e318329d1d101107862d.tar.gz external_llvm-a2440259c7bc10102f92e318329d1d101107862d.tar.bz2 | |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94850 91177308-0d34-0410-b5e6-96231b3b80d8
| -rw-r--r-- | lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp index 306ed67..e58c954 100644 --- a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/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); } |
