diff options
author | Dan Gohman <gohman@apple.com> | 2007-07-20 16:34:21 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2007-07-20 16:34:21 +0000 |
commit | 9941f7426ddef3a9f9de4b82630deaf4756fd924 (patch) | |
tree | 34a2ad0fbf9a37a65205c14b975719c89ab25d06 /lib/Transforms | |
parent | 9bc5dce98d5607b2661e7233378e294a6dec1b78 (diff) | |
download | external_llvm-9941f7426ddef3a9f9de4b82630deaf4756fd924.zip external_llvm-9941f7426ddef3a9f9de4b82630deaf4756fd924.tar.gz external_llvm-9941f7426ddef3a9f9de4b82630deaf4756fd924.tar.bz2 |
Optimize alignment of loads and stores.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40102 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 816a1c6..33fd843 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -8790,6 +8790,11 @@ static bool isSafeToLoadUnconditionally(Value *V, Instruction *ScanFrom) { Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { Value *Op = LI.getOperand(0); + // Attempt to improve the alignment. + unsigned KnownAlign = GetKnownAlignment(Op, TD); + if (KnownAlign > LI.getAlignment()) + LI.setAlignment(KnownAlign); + // load (cast X) --> cast (load X) iff safe if (isa<CastInst>(Op)) if (Instruction *Res = InstCombineLoadCast(*this, LI)) @@ -8985,6 +8990,11 @@ Instruction *InstCombiner::visitStoreInst(StoreInst &SI) { } } + // Attempt to improve the alignment. + unsigned KnownAlign = GetKnownAlignment(Ptr, TD); + if (KnownAlign > SI.getAlignment()) + SI.setAlignment(KnownAlign); + // Do really simple DSE, to catch cases where there are several consequtive // stores to the same location, separated by a few arithmetic operations. This // situation often occurs with bitfield accesses. |