1 ; RUN: opt -inline %s -S | FileCheck %s
3 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
4 target triple = "thumbv7m-arm-none-eabi"
6 ; CHECK-LABEL: define void @matcpy
7 define void @matcpy(i8* %dest, i8* %source, i32 %num) #0 {
9 %0 = ptrtoint i8* %dest to i32
10 %1 = ptrtoint i8* %source to i32
13 %cmp = icmp eq i32 %3, 0
14 br i1 %cmp, label %if.then, label %if.else20
16 if.then: ; preds = %entry
18 %and2 = and i32 %sub, 3
19 %add = or i32 %and2, 4
20 %cmp3 = icmp ugt i32 %add, %num
21 br i1 %cmp3, label %if.else, label %if.then4
23 if.then4: ; preds = %if.then
24 %sub5 = sub i32 %num, %and2
25 %shr = and i32 %sub5, -4
26 %sub7 = sub i32 %sub5, %shr
27 %tobool = icmp eq i32 %and2, 0
28 br i1 %tobool, label %if.end, label %if.then8
30 if.then8: ; preds = %if.then4
31 ; CHECK: call fastcc void @memcpy
32 call fastcc void @memcpy(i8* %dest, i8* %source, i32 %and2) #0
33 %add.ptr = getelementptr inbounds i8, i8* %dest, i32 %and2
34 %add.ptr9 = getelementptr inbounds i8, i8* %source, i32 %and2
37 if.end: ; preds = %if.then4, %if.then8
38 %p_dest.0 = phi i8* [ %add.ptr, %if.then8 ], [ %dest, %if.then4 ]
39 %p_source.0 = phi i8* [ %add.ptr9, %if.then8 ], [ %source, %if.then4 ]
40 %tobool14 = icmp eq i32 %sub7, 0
41 br i1 %tobool14, label %if.end22, label %if.then15
43 if.then15: ; preds = %if.end
44 %add.ptr13 = getelementptr inbounds i8, i8* %p_source.0, i32 %shr
45 %add.ptr11 = getelementptr inbounds i8, i8* %p_dest.0, i32 %shr
46 ; CHECK: call fastcc void @memcpy
47 call fastcc void @memcpy(i8* %add.ptr11, i8* %add.ptr13, i32 %sub7) #0
50 if.else: ; preds = %if.then
51 call fastcc void @memcpy(i8* %dest, i8* %source, i32 %num) #0
54 if.else20: ; preds = %entry
55 call fastcc void @memcpy(i8* %dest, i8* %source, i32 %num) #0
58 if.end22: ; preds = %if.then15, %if.end, %if.else, %if.else20
62 ; CHECK-LABEL: define internal void @memcpy
63 define internal void @memcpy(i8* nocapture %dest, i8* nocapture readonly %source, i32 %num) #0 {
67 while.cond: ; preds = %while.body, %entry
68 %num.addr.0 = phi i32 [ %num, %entry ], [ %dec, %while.body ]
69 %p_dest.0 = phi i8* [ %dest, %entry ], [ %incdec.ptr1, %while.body ]
70 %p_source.0 = phi i8* [ %source, %entry ], [ %incdec.ptr, %while.body ]
71 %cmp = icmp eq i32 %num.addr.0, 0
72 br i1 %cmp, label %while.end, label %while.body
74 while.body: ; preds = %while.cond
75 %incdec.ptr = getelementptr inbounds i8, i8* %p_source.0, i32 1
76 %0 = load i8, i8* %p_source.0, align 1
77 %incdec.ptr1 = getelementptr inbounds i8, i8* %p_dest.0, i32 1
78 store i8 %0, i8* %p_dest.0, align 1
79 %dec = add i32 %num.addr.0, -1
82 while.end: ; preds = %while.cond
86 attributes #0 = { minsize optsize }