1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc < %s | FileCheck %s
3 target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
4 target triple = "thumbv7-unknown-linux-gnueabihf"
6 %Target = type { ptr, ptr }
7 %List = type { i32, ptr }
9 ; The entry block should be the first block of the function.
11 define i1 @foo(ptr %ha, i32 %he) !prof !39 {
13 ; CHECK: @ %bb.0: @ %entry
14 ; CHECK-NEXT: ldr r2, [r0]
15 ; CHECK-NEXT: cmp r2, #0
17 ; CHECK-NEXT: moveq r0, #0
19 ; CHECK-NEXT: .LBB0_1: @ %for.body.preheader
20 ; CHECK-NEXT: .save {r7, lr}
21 ; CHECK-NEXT: push {r7, lr}
22 ; CHECK-NEXT: b .LBB0_3
23 ; CHECK-NEXT: .LBB0_2: @ %for.inc
24 ; CHECK-NEXT: @ in Loop: Header=BB0_3 Depth=1
25 ; CHECK-NEXT: ldr r2, [r2]
26 ; CHECK-NEXT: movs r0, #0
27 ; CHECK-NEXT: cmp r2, #0
29 ; CHECK-NEXT: popeq {r7, pc}
30 ; CHECK-NEXT: .LBB0_3: @ %for.body
31 ; CHECK-NEXT: @ =>This Loop Header: Depth=1
32 ; CHECK-NEXT: @ Child Loop BB0_5 Depth 2
33 ; CHECK-NEXT: ldr r0, [r2, #4]
34 ; CHECK-NEXT: cmp r0, #0
35 ; CHECK-NEXT: beq .LBB0_2
36 ; CHECK-NEXT: @ %bb.4: @ %if.then
37 ; CHECK-NEXT: @ in Loop: Header=BB0_3 Depth=1
38 ; CHECK-NEXT: ldrd r3, r0, [r0]
39 ; CHECK-NEXT: sub.w r12, r0, #4
40 ; CHECK-NEXT: .LBB0_5: @ %for.cond.i
41 ; CHECK-NEXT: @ Parent Loop BB0_3 Depth=1
42 ; CHECK-NEXT: @ => This Inner Loop Header: Depth=2
43 ; CHECK-NEXT: cmp r3, #1
44 ; CHECK-NEXT: blt .LBB0_2
45 ; CHECK-NEXT: @ %bb.6: @ %for.body.i
46 ; CHECK-NEXT: @ in Loop: Header=BB0_5 Depth=2
47 ; CHECK-NEXT: ldr.w lr, [r12, r3, lsl #2]
48 ; CHECK-NEXT: subs r3, #1
49 ; CHECK-NEXT: movs r0, #1
50 ; CHECK-NEXT: cmp lr, r1
51 ; CHECK-NEXT: bne .LBB0_5
52 ; CHECK-NEXT: @ %bb.7:
53 ; CHECK-NEXT: pop {r7, pc}
55 %TargetPtr = load ptr, ptr %ha, align 4
56 %cmp1 = icmp eq ptr %TargetPtr, null
57 br i1 %cmp1, label %return, label %for.body, !prof !50
60 %TargetPhi = phi ptr [ %NextPtr, %for.inc ], [ %TargetPtr, %entry ]
61 %ListAddr = getelementptr inbounds %Target, ptr %TargetPhi, i32 0, i32 1
62 %ListPtr = load ptr, ptr %ListAddr, align 4
63 %cmp2 = icmp eq ptr %ListPtr, null
64 br i1 %cmp2, label %for.inc, label %if.then, !prof !59
67 %len = load i32, ptr %ListPtr, align 4
68 %ptr = getelementptr inbounds %List, ptr %ListPtr, i32 0, i32 1
69 %ptr2 = load ptr, ptr %ptr, align 4
73 %i = phi i32 [ %len, %if.then ], [ %index, %for.body.i ]
74 %index = add nsw i32 %i, -1
75 %cmp3 = icmp sgt i32 %i, 0
76 br i1 %cmp3, label %for.body.i, label %for.inc, !prof !75
79 %ptr3 = getelementptr inbounds i32, ptr %ptr2, i32 %index
80 %data = load i32, ptr %ptr3, align 4
81 %cmp4 = icmp eq i32 %data, %he
82 br i1 %cmp4, label %return, label %for.cond.i, !prof !79
85 %NextPtr = load ptr, ptr %TargetPhi, align 4
86 %cmp5 = icmp eq ptr %NextPtr, null
87 br i1 %cmp5, label %return, label %for.body, !prof !50
90 %retval = phi i1 [ false, %entry ], [ true, %for.body.i ], [ false, %for.inc ]
94 !39 = !{!"function_entry_count", i64 226}
95 !50 = !{!"branch_weights", i32 451, i32 1}
96 !59 = !{!"branch_weights", i32 1502, i32 1}
97 !75 = !{!"branch_weights", i32 301, i32 1}
98 !79 = !{!"branch_weights", i32 1, i32 301}