mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-21 19:36:59 +00:00
Slightly generalize transformation of memmove(a,a,n) so that it also applies
to memcpy. (Such a memcpy is technically illegal, but in practice is safe and is generated by struct self-assignment in C code.) llvm-svn: 91621
This commit is contained in:
parent
d43aca2c4d
commit
ff5c248066
@ -9896,9 +9896,11 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
|
||||
Intrinsic::getDeclaration(M, MemCpyID, Tys, 1));
|
||||
Changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (MemTransferInst *MTI = dyn_cast<MemTransferInst>(MI)) {
|
||||
// memmove(x,x,size) -> noop.
|
||||
if (MMI->getSource() == MMI->getDest())
|
||||
if (MTI->getSource() == MTI->getDest())
|
||||
return EraseInstFromFunction(CI);
|
||||
}
|
||||
|
||||
|
10
test/Transforms/InstCombine/memcpy.ll
Normal file
10
test/Transforms/InstCombine/memcpy.ll
Normal file
@ -0,0 +1,10 @@
|
||||
; RUN: opt < %s -instcombine -S | FileCheck %s
|
||||
|
||||
declare void @llvm.memcpy.i32(i8*, i8*, i32, i32)
|
||||
|
||||
define void @test4(i8* %a) {
|
||||
tail call void @llvm.memcpy.i32( i8* %a, i8* %a, i32 100, i32 1 )
|
||||
ret void
|
||||
}
|
||||
; CHECK: define void @test4
|
||||
; CHECK-NEXT: ret void
|
Loading…
x
Reference in New Issue
Block a user