[PATCH] TargetLibraryInfo: Disable memcpy and memset on R600

Nick Lewycky nicholas at mxc.ca
Fri Mar 7 11:33:12 PST 2014


Tom Stellard wrote:
> There is no implementation of these on R600.
> ---
>   lib/Target/TargetLibraryInfo.cpp | 11 +++++++-
>   test/CodeGen/R600/loop-idiom.ll  | 54 ++++++++++++++++++++++++++++++++++++++++
>   2 files changed, 64 insertions(+), 1 deletion(-)
>   create mode 100644 test/CodeGen/R600/loop-idiom.ll
>
> diff --git a/lib/Target/TargetLibraryInfo.cpp b/lib/Target/TargetLibraryInfo.cpp
> index 46cce84..86784f5 100644
> --- a/lib/Target/TargetLibraryInfo.cpp
> +++ b/lib/Target/TargetLibraryInfo.cpp
> @@ -378,7 +378,16 @@ static void initialize(TargetLibraryInfo&TLI, const Triple&T,
>         llvm_unreachable("TargetLibraryInfo function names must be sorted");
>     }
>   #endif // !NDEBUG
> -
> +
> +  // There are no library implementations of mempcy and memset for r600 and
> +  // these can be difficult to lower in the backend.
> +  if (T.getArch() == Triple::r600) {
> +    TLI.setUnavailable(LibFunc::memcpy);
> +    TLI.setUnavailable(LibFunc::memset);
> +    TLI.setUnavailable(LibFunc::memset_pattern16);
> +    return;
> +  }
> +
>     // memset_pattern16 is only available on iOS 3.0 and Mac OS/X 10.5 and later.
>     if (T.isMacOSX()) {
>       if (T.isMacOSXVersionLT(10, 5))
> diff --git a/test/CodeGen/R600/loop-idiom.ll b/test/CodeGen/R600/loop-idiom.ll
> new file mode 100644
> index 0000000..a56e0b8
> --- /dev/null
> +++ b/test/CodeGen/R600/loop-idiom.ll
> @@ -0,0 +1,54 @@
> +; RUN: opt -basicaa -loop-idiom -S<  %s -march=r600 -mcpu=redwood | FileCheck --check-prefix=R600 --check-prefix=FUNC %s
> +; RUN: opt -basicaa -loop-idiom -S<  %s -march=r600 -mcpu=SI | FileCheck --check-prefix=SI --check-prefix=FUNC %s
> +
> +target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:64:64-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
> +target triple = "r600--"
> +
> +
> +
> +; Make sure loop-idiom doesn't create memcpy or memset.  There are no library
> +; implemtations of thses on R600.

"implementations". "these".

> +
> +; FUNC: @no_memcpy
> +; R600-NOT: @llvm.memcpy
> +; SI-NOT: @llvm.memcpy
> +define void @no_memcpy(i8 addrspace(3)* %in, i32 %size) {
> +entry:
> +  %dest = alloca i8, i32 32
> +  br label %for.body
> +
> +for.body:
> +  %0 = phi i32 [0, %entry], [%4, %for.body]
> +  %1 = getelementptr i8 addrspace(3)* %in, i32 %0
> +  %2 = getelementptr i8* %dest, i32 %0
> +  %3 = load i8 addrspace(3)* %1
> +  store i8 %3, i8* %2
> +  %4 = add i32 %0, 1
> +  %5 = icmp eq i32 %4, %size
> +  br i1 %5, label %for.end, label %for.body
> +
> +for.end:
> +  ret void
> +}
> +
> +; FUNC: @no_memset
> +; R600-NOT: @llvm.memset
> +; R600-NOT: @memset_pattern16
> +; SI-NOT: @llvm.memset
> +; SI-NOT: @memset_pattern16
> +define void @no_memset(i32 %size) {
> +entry:
> +  %dest = alloca i8, i32 32
> +  br label %for.body
> +
> +for.body:
> +  %0 = phi i32 [0, %entry], [%2, %for.body]
> +  %1 = getelementptr i8* %dest, i32 %0
> +  store i8 0, i8* %1
> +  %2 = add i32 %0, 1
> +  %3 = icmp eq i32 %2, %size
> +  br i1 %3, label %for.end, label %for.body
> +
> +for.end:
> +  ret void
> +}




More information about the llvm-commits mailing list