• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -inline < %s -S -o - -inline-threshold=10 | FileCheck %s
2
3target datalayout = "p:32:32"
4
5define i32 @outer1() {
6; CHECK: @outer1
7; CHECK-NOT: call
8; CHECK: ret i32
9
10  %ptr = alloca i32
11  %ptr1 = getelementptr inbounds i32* %ptr, i32 0
12  %ptr2 = getelementptr inbounds i32* %ptr, i32 42
13  %result = call i32 @inner1(i32* %ptr1, i32* %ptr2)
14  ret i32 %result
15}
16
17define i32 @inner1(i32* %begin, i32* %end) {
18  %begin.i = ptrtoint i32* %begin to i32
19  %end.i = ptrtoint i32* %end to i32
20  %distance = sub i32 %end.i, %begin.i
21  %icmp = icmp sle i32 %distance, 42
22  br i1 %icmp, label %then, label %else
23
24then:
25  ret i32 3
26
27else:
28  %t = load i32* %begin
29  ret i32 %t
30}
31
32define i32 @outer2(i32* %ptr) {
33; Test that an inbounds GEP disables this -- it isn't safe in general as
34; wrapping changes the behavior of lessthan and greaterthan comparisions.
35; CHECK: @outer2
36; CHECK: call i32 @inner2
37; CHECK: ret i32
38
39  %ptr1 = getelementptr i32* %ptr, i32 0
40  %ptr2 = getelementptr i32* %ptr, i32 42
41  %result = call i32 @inner2(i32* %ptr1, i32* %ptr2)
42  ret i32 %result
43}
44
45define i32 @inner2(i32* %begin, i32* %end) {
46  %begin.i = ptrtoint i32* %begin to i32
47  %end.i = ptrtoint i32* %end to i32
48  %distance = sub i32 %end.i, %begin.i
49  %icmp = icmp sle i32 %distance, 42
50  br i1 %icmp, label %then, label %else
51
52then:
53  ret i32 3
54
55else:
56  %t = load i32* %begin
57  ret i32 %t
58}
59