[PATCH] Optimize double storing by memset; memcpy

Chandler Carruth chandlerc at google.com
Sun Mar 3 23:31:30 PST 2013


On Sun, Mar 3, 2013 at 11:24 PM, Joel Jones <joel_k_jones at apple.com> wrote:

>   This is the C source from the clang repo.
>

Clang shouldn't be providing tests for LLVM's optimizers ever really. While
we have some, the number should really decrease. (There are a very few
exceptions, but this certainly doesn't seem like one...)

Instead, if you want to test this, check that clang (without any
optimizations) emits the particular IR patterns of interest. Then provide
LLVM-based IR->IR tests which isolate the simplifications you expect to
happen here entirely within the LLVM pipeline.


>
> 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);
> +}
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130303/e56d2c45/attachment.html>


More information about the llvm-commits mailing list