http://llvm.org/bugs/show_bug.cgi?id=22758
Bug ID: 22758
Summary: [memcpyopt] Missed memcpy->memset optimization
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Scalar Optimizations
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
We currently don't have a dedicated memcpy to memset conversion optimization.
We're instead relying on a call slot optimization which is unneccessary
restrictive. In particular, it is only the contents of the source region of
memory which needs to be known, not the contents of the destination memory.
In the example below, we put a non-zero value into the destination location,
and then immediately copy zeros over it. We fail to convert the memcpy to a
memset if we run only memcpyopt.
Note that DSE does eliminate the dead store and thus the combination works just
fine. You could find an example that didn't (maybe a partially dead store?),
but I didn't bother for the purposes of reporting this.
target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
declare void @foo([100000 x i32]*)
; Function Attrs: nounwind
declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) #0
; Function Attrs: nounwind
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly,
i64, i32, i1) #0
define void @testfunc() {
%src = alloca [100000 x i32], align 4
%dst = alloca [100000 x i32], align 4
%1 = bitcast [100000 x i32]* %src to i8*
%2 = bitcast [100000 x i32]* %dst to i8*
call void @llvm.memset.p0i8.i64(i8* %1, i8 0, i64 400000, i32 4, i1 false)
store i8 47, i8* %2
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %2, i8* %1, i64 400000, i32 4, i1
false)
call void @foo([100000 x i32]* %dst)
ret void
}
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs