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: void @doCalls
7 define void @doCalls(i8* nocapture %p1, i8* nocapture %p2, i32 %n) #0 {
10 ; CHECK: call void @LoopCall
11 tail call void @LoopCall(i8* %p1, i8* %p2, i32 %div) #0
13 %div2 = lshr i32 %n, 2
14 ; CHECK: call void @LoopCall
15 tail call void @LoopCall(i8* %p1, i8* %p2, i32 %div2) #0
17 ; CHECK-NOT: call void @LoopCall
18 tail call void @LoopCall(i8* %p2, i8* %p1, i32 0) #0
20 ; CHECK-NOT: call void @LoopCall_internal
21 tail call void @LoopCall_internal(i8* %p1, i8* %p2, i32 %div2) #0
23 %div3 = lshr i32 %n, 4
24 ; CHECK-NOT: call void @SimpleCall
25 tail call void @SimpleCall(i8* %p2, i8* %p1, i32 %div3) #0
29 ; CHECK-LABEL: define void @LoopCall
30 define void @LoopCall(i8* nocapture %dest, i8* nocapture readonly %source, i32 %num) #0 {
32 %c = icmp ne i32 %num, 0
33 br i1 %c, label %while.cond, label %while.end
35 while.cond: ; preds = %while.body, %entry
36 %num.addr.0 = phi i32 [ %num, %entry ], [ %dec, %while.body ]
37 %p_dest.0 = phi i8* [ %dest, %entry ], [ %incdec.ptr2, %while.body ]
38 %p_source.0 = phi i8* [ %source, %entry ], [ %incdec.ptr, %while.body ]
39 %cmp = icmp eq i32 %num.addr.0, 0
40 br i1 %cmp, label %while.end, label %while.body
42 while.body: ; preds = %while.cond
43 %incdec.ptr = getelementptr inbounds i8, i8* %p_source.0, i32 1
44 %0 = load i8, i8* %p_source.0, align 1
45 %1 = trunc i32 %num.addr.0 to i8
46 %conv1 = add i8 %0, %1
47 %incdec.ptr2 = getelementptr inbounds i8, i8* %p_dest.0, i32 1
48 store i8 %conv1, i8* %p_dest.0, align 1
49 %dec = add i32 %num.addr.0, -1
52 while.end: ; preds = %while.cond
56 ; CHECK-LABEL-NOT: define void @LoopCall_internal
57 define internal void @LoopCall_internal(i8* nocapture %dest, i8* nocapture readonly %source, i32 %num) #0 {
59 %c = icmp ne i32 %num, 0
60 br i1 %c, label %while.cond, label %while.end
62 while.cond: ; preds = %while.body, %entry
63 %num.addr.0 = phi i32 [ %num, %entry ], [ %dec, %while.body ]
64 %p_dest.0 = phi i8* [ %dest, %entry ], [ %incdec.ptr2, %while.body ]
65 %p_source.0 = phi i8* [ %source, %entry ], [ %incdec.ptr, %while.body ]
66 %cmp = icmp eq i32 %num.addr.0, 0
67 br i1 %cmp, label %while.end, label %while.body
69 while.body: ; preds = %while.cond
70 %incdec.ptr = getelementptr inbounds i8, i8* %p_source.0, i32 1
71 %0 = load i8, i8* %p_source.0, align 1
72 %1 = trunc i32 %num.addr.0 to i8
73 %conv1 = add i8 %0, %1
74 %incdec.ptr2 = getelementptr inbounds i8, i8* %p_dest.0, i32 1
75 store i8 %conv1, i8* %p_dest.0, align 1
76 %dec = add i32 %num.addr.0, -1
79 while.end: ; preds = %while.cond
83 ; CHECK-LABEL: define void @SimpleCall
84 define void @SimpleCall(i8* nocapture %dest, i8* nocapture readonly %source, i32 %num) #0 {
86 %arrayidx = getelementptr inbounds i8, i8* %source, i32 %num
87 %0 = load i8, i8* %arrayidx, align 1
89 %arrayidx2 = getelementptr inbounds i8, i8* %dest, i32 %num
90 store i8 %1, i8* %arrayidx2, align 1
94 attributes #0 = { minsize optsize }