1 ; Test that the memmove library call simplifier works correctly.
3 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
5 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
7 declare ptr @memmove(ptr, ptr, i32)
9 ; Check memmove(mem1, mem2, size) -> llvm.memmove(mem1, mem2, size, 1).
11 define ptr @test_simplify1(ptr %mem1, ptr %mem2, i32 %size) {
12 ; CHECK-LABEL: @test_simplify1(
13 %ret = call ptr @memmove(ptr %mem1, ptr %mem2, i32 %size)
14 ; CHECK: call void @llvm.memmove
16 ; CHECK: ret ptr %mem1
19 define ptr @test_simplify2(ptr %mem1, ptr %mem2, i32 %size) {
20 ; CHECK-LABEL: @test_simplify2(
21 ; CHECK-NEXT: tail call void @llvm.memmove
22 ; CHECK-NEXT: ret ptr %mem1
23 %ret = tail call ptr @memmove(ptr %mem1, ptr %mem2, i32 %size)
27 define ptr @test_no_simplify1(ptr %mem1, ptr %mem2, i32 %size) {
28 ; CHECK-LABEL: @test_no_simplify1(
29 ; CHECK-NEXT: %ret = musttail call ptr @memmove(ptr %mem1, ptr %mem2, i32 %size)
30 ; CHECK-NEXT: ret ptr %ret
31 %ret = musttail call ptr @memmove(ptr %mem1, ptr %mem2, i32 %size)
35 define ptr @test_no_incompatible_attr(ptr %mem1, ptr %mem2, i32 %size) {
36 ; CHECK-LABEL: @test_no_incompatible_attr(
37 %ret = call dereferenceable(1) ptr @memmove(ptr %mem1, ptr %mem2, i32 %size)
38 ; CHECK: call void @llvm.memmove
40 ; CHECK: ret ptr %mem1