1; RUN: opt -inline %s -S | FileCheck %s 2 3target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" 4target triple = "thumbv7m-arm-none-eabi" 5 6; CHECK-LABEL: define void @matcpy 7define void @matcpy(i8* %dest, i8* %source, i32 %num) #0 { 8entry: 9 %0 = ptrtoint i8* %dest to i32 10 %1 = ptrtoint i8* %source to i32 11 %2 = xor i32 %0, %1 12 %3 = and i32 %2, 3 13 %cmp = icmp eq i32 %3, 0 14 br i1 %cmp, label %if.then, label %if.else20 15 16if.then: ; preds = %entry 17 %sub = sub i32 0, %0 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 22 23if.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 29 30if.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 35 br label %if.end 36 37if.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 42 43if.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 48 br label %if.end22 49 50if.else: ; preds = %if.then 51 call fastcc void @memcpy(i8* %dest, i8* %source, i32 %num) #0 52 br label %if.end22 53 54if.else20: ; preds = %entry 55 call fastcc void @memcpy(i8* %dest, i8* %source, i32 %num) #0 56 br label %if.end22 57 58if.end22: ; preds = %if.then15, %if.end, %if.else, %if.else20 59 ret void 60} 61 62; CHECK-LABEL: define internal void @memcpy 63define internal void @memcpy(i8* nocapture %dest, i8* nocapture readonly %source, i32 %num) #0 { 64entry: 65 br label %while.cond 66 67while.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 73 74while.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 80 br label %while.cond 81 82while.end: ; preds = %while.cond 83 ret void 84} 85 86attributes #0 = { minsize optsize } 87 88