[PATCH] Optimize double storing by memset; memcpy

Joel Jones joel_k_jones at apple.com
Sun Mar 3 23:24:02 PST 2013


  This is the C source from the clang repo.

http://llvm-reviews.chandlerc.com/D489

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D489?vs=1179&id=1180#toc

Files:
  test/CodeGen/memSetCpy.c

Index: test/CodeGen/memSetCpy.c
===================================================================
--- test/CodeGen/memSetCpy.c
+++ test/CodeGen/memSetCpy.c
@@ -0,0 +1,16 @@
+// RUN: %clang -O3 -S -emit-llvm  %s -o - | FileCheck %s
+// Note: using clang here as it is very easy to end up with C source that
+// doesn't actually produce llvm.mem* intrinsics that the memset; memcpy
+// argument rewriting depends upon.  This test may be too fragile in the form
+// here.  Another LLVM IR only source file tests the transformation as well,
+// and is less dependent upon host compilation environments.
+
+#include <strings.h>
+
+void foo(char* src, int src_size, char* dest, int dest_size)
+{
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dest, i8* %src,
+// CHECK: call void @llvm.memset.p0i8.i64(i8*
+  memset(dest, 0, dest_size);
+  memcpy(dest, src, src_size);
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D489.2.patch
Type: text/x-patch
Size: 874 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130303/92c4b942/attachment.bin>


More information about the llvm-commits mailing list