diff options
author | Artur Pilipenko <apilipenko@azulsystems.com> | 2015-11-02 17:53:51 +0000 |
---|---|---|
committer | Artur Pilipenko <apilipenko@azulsystems.com> | 2015-11-02 17:53:51 +0000 |
commit | 5c5011d503fa8c2d225f947adec3bda6141b91c5 (patch) | |
tree | 8960d95cb25d67ab261f4952230cf04e1168ac9f /llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp | |
parent | 5daa9b231f5ba14ee8dd902260c8edae13cc01de (diff) | |
download | bcm5719-llvm-5c5011d503fa8c2d225f947adec3bda6141b91c5.tar.gz bcm5719-llvm-5c5011d503fa8c2d225f947adec3bda6141b91c5.zip |
Preserve load alignment and dereferenceable metadata during some transformations
Reviewed By: hfinkel
Differential Revision: http://reviews.llvm.org/D13953
llvm-svn: 251809
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp index 4fba7f95797..933849f460b 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -367,7 +367,13 @@ static LoadInst *combineLoadToNewType(InstCombiner &IC, LoadInst &LI, Type *NewT MDB.createRange(NonNullInt, NullInt)); } break; - + case LLVMContext::MD_align: + case LLVMContext::MD_dereferenceable: + case LLVMContext::MD_dereferenceable_or_null: + // These only directly apply if the new type is also a pointer. + if (NewTy->isPointerTy()) + NewLoad->setMetadata(ID, N); + break; case LLVMContext::MD_range: // FIXME: It would be nice to propagate this in some way, but the type // conversions make it hard. If the new type is a pointer, we could @@ -418,6 +424,9 @@ static StoreInst *combineStoreToNewValue(InstCombiner &IC, StoreInst &SI, Value case LLVMContext::MD_invariant_load: case LLVMContext::MD_nonnull: case LLVMContext::MD_range: + case LLVMContext::MD_align: + case LLVMContext::MD_dereferenceable: + case LLVMContext::MD_dereferenceable_or_null: // These don't apply for stores. break; } @@ -755,10 +764,12 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { DefMaxInstsToScan, AA, &AATags)) { if (LoadInst *NLI = dyn_cast<LoadInst>(AvailableVal)) { unsigned KnownIDs[] = { - LLVMContext::MD_tbaa, LLVMContext::MD_alias_scope, - LLVMContext::MD_noalias, LLVMContext::MD_range, - LLVMContext::MD_invariant_load, LLVMContext::MD_nonnull, - LLVMContext::MD_invariant_group}; + LLVMContext::MD_tbaa, LLVMContext::MD_alias_scope, + LLVMContext::MD_noalias, LLVMContext::MD_range, + LLVMContext::MD_invariant_load, LLVMContext::MD_nonnull, + LLVMContext::MD_invariant_group, LLVMContext::MD_align, + LLVMContext::MD_dereferenceable, + LLVMContext::MD_dereferenceable_or_null}; combineMetadata(NLI, &LI, KnownIDs); }; |