mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-09 05:57:23 +00:00
Fix PR26051: Memcpy optimization should introduce a call to memcpy before the store destination position
This is a conservative fix, I expect Amaury to relax this. Follow-up for r256923 From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256999 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3442ec90cd
commit
7fee368539
@ -529,11 +529,13 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator &BBI) {
|
|||||||
|
|
||||||
// We found an instruction that may write to the loaded memory.
|
// We found an instruction that may write to the loaded memory.
|
||||||
// We can try to promote at this position instead of the store
|
// We can try to promote at this position instead of the store
|
||||||
// position if nothing alias the store memory after this.
|
// position if nothing alias the store memory after this and the store
|
||||||
|
// destination is not in the range.
|
||||||
P = &*I;
|
P = &*I;
|
||||||
for (; I != E; ++I) {
|
for (; I != E; ++I) {
|
||||||
MemoryLocation StoreLoc = MemoryLocation::get(SI);
|
MemoryLocation StoreLoc = MemoryLocation::get(SI);
|
||||||
if (AA.getModRefInfo(&*I, StoreLoc) != MRI_NoModRef) {
|
if (&*I == SI->getOperand(1) ||
|
||||||
|
AA.getModRefInfo(&*I, StoreLoc) != MRI_NoModRef) {
|
||||||
P = nullptr;
|
P = nullptr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -72,3 +72,17 @@ define void @copyalias(%S* %src, %S* %dst) {
|
|||||||
store %S %2, %S* %dst
|
store %S %2, %S* %dst
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; The GEP is present after the aliasing store, preventing to move the memcpy before
|
||||||
|
; (without further analysis/transformation)
|
||||||
|
define void @copyaliaswithproducerinbetween(%S* %src, %S* %dst) {
|
||||||
|
; CHECK-LABEL: copyalias
|
||||||
|
; CHECK-NEXT: [[LOAD:%[a-z0-9\.]+]] = load %S, %S* %src
|
||||||
|
; CHECK-NOT: call
|
||||||
|
%1 = load %S, %S* %src
|
||||||
|
store %S undef, %S* %dst
|
||||||
|
%dst2 = getelementptr %S , %S* %dst, i64 1
|
||||||
|
store %S %1, %S* %dst2
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user