• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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: void @doCalls
7define void @doCalls(i8* nocapture %p1, i8* nocapture %p2, i32 %n) #0 {
8entry:
9  %div = lshr i32 %n, 1
10; CHECK: call void @LoopCall
11  tail call void @LoopCall(i8* %p1, i8* %p2, i32 %div) #0
12
13  %div2 = lshr i32 %n, 2
14; CHECK: call void @LoopCall
15  tail call void @LoopCall(i8* %p1, i8* %p2, i32 %div2) #0
16
17; CHECK-NOT: call void @LoopCall
18  tail call void @LoopCall(i8* %p2, i8* %p1, i32 0) #0
19
20; CHECK-NOT: call void @LoopCall_internal
21  tail call void @LoopCall_internal(i8* %p1, i8* %p2, i32 %div2) #0
22
23  %div3 = lshr i32 %n, 4
24; CHECK-NOT: call void @SimpleCall
25  tail call void @SimpleCall(i8* %p2, i8* %p1, i32 %div3) #0
26  ret void
27}
28
29; CHECK-LABEL: define void @LoopCall
30define void @LoopCall(i8* nocapture %dest, i8* nocapture readonly %source, i32 %num) #0 {
31entry:
32  %c = icmp ne i32 %num, 0
33  br i1 %c, label %while.cond, label %while.end
34
35while.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
41
42while.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
50  br label %while.cond
51
52while.end:                                        ; preds = %while.cond
53  ret void
54}
55
56; CHECK-LABEL-NOT: define void @LoopCall_internal
57define internal void @LoopCall_internal(i8* nocapture %dest, i8* nocapture readonly %source, i32 %num) #0 {
58entry:
59  %c = icmp ne i32 %num, 0
60  br i1 %c, label %while.cond, label %while.end
61
62while.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
68
69while.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
77  br label %while.cond
78
79while.end:                                        ; preds = %while.cond
80  ret void
81}
82
83; CHECK-LABEL: define void @SimpleCall
84define void @SimpleCall(i8* nocapture %dest, i8* nocapture readonly %source, i32 %num) #0 {
85entry:
86  %arrayidx = getelementptr inbounds i8, i8* %source, i32 %num
87  %0 = load i8, i8* %arrayidx, align 1
88  %1 = xor i8 %0, 127
89  %arrayidx2 = getelementptr inbounds i8, i8* %dest, i32 %num
90  store i8 %1, i8* %arrayidx2, align 1
91  ret void
92}
93
94attributes #0 = { minsize optsize }
95
96