diff options
author | Eric Christopher <echristo@apple.com> | 2010-10-01 09:02:05 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2010-10-01 09:02:05 +0000 |
commit | 3ad2f3a2f211fac8e9f0f5f4640d258dfec3e798 (patch) | |
tree | 12a0dec74834b30c920c7141b8e80c574d5d6ee9 /llvm/lib/Transforms | |
parent | 3b2b1e794242b96121cc696dc72d35d911bc82f6 (diff) | |
download | bcm5719-llvm-3ad2f3a2f211fac8e9f0f5f4640d258dfec3e798.tar.gz bcm5719-llvm-3ad2f3a2f211fac8e9f0f5f4640d258dfec3e798.zip |
Fix the other half of the alignment changing issue by making sure that the
memcpy alignment is the minimum of the incoming alignments.
Fixes PR 8266.
llvm-svn: 115305
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp index f94c9e22576..4172b345c61 100644 --- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -697,13 +697,18 @@ bool MemCpyOpt::processMemCpy(MemCpyInst *M) { M->getParent()->getParent()->getParent(), M->getIntrinsicID(), ArgTys, 3); - // Make sure to use the alignment of the source since we're changing the - // location we're reading from. + // Make sure to use the lesser of the alignment of the source and the dest + // since we're changing where we're reading from, but don't want to increase + // the alignment past what can be read from or written to. // TODO: Is this worth it if we're creating a less aligned memcpy? For // example we could be moving from movaps -> movq on x86. + unsigned Align = std::min(MDep->getAlignmentCst()->getZExtValue(), + M->getAlignmentCst()->getZExtValue()); + LLVMContext &Context = M->getContext(); + ConstantInt *AlignCI = ConstantInt::get(Type::getInt32Ty(Context), Align); Value *Args[5] = { M->getRawDest(), MDep->getRawSource(), M->getLength(), - MDep->getAlignmentCst(), M->getVolatileCst() + AlignCI, M->getVolatileCst() }; CallInst *C = CallInst::Create(MemCpyFun, Args, Args+5, "", M); |