1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -verify-machineinstrs -mtriple=arm-unknown-linux < %s | FileCheck %s
3
4; Check CSR split can work properly for tests below.
5
6@a = common dso_local local_unnamed_addr global i32 0, align 4
7
8define dso_local signext i32 @test1(i32* %b) local_unnamed_addr  {
9; CHECK-LABEL: test1:
10; CHECK:       @ %bb.0: @ %entry
11; CHECK-NEXT:    push {r4, lr}
12; CHECK-NEXT:    mov r4, r0
13; CHECK-NEXT:    ldr r0, .LCPI0_0
14; CHECK-NEXT:    ldr r0, [r0]
15; CHECK-NEXT:    cmp r0, r4
16; CHECK-NEXT:    popne {r4, lr}
17; CHECK-NEXT:    movne pc, lr
18; CHECK-NEXT:  .LBB0_1: @ %if.then
19; CHECK-NEXT:    bl callVoid
20; CHECK-NEXT:    mov r0, r4
21; CHECK-NEXT:    pop {r4, lr}
22; CHECK-NEXT:    b callNonVoid
23; CHECK-NEXT:    .p2align 2
24; CHECK-NEXT:  @ %bb.2:
25; CHECK-NEXT:  .LCPI0_0:
26; CHECK-NEXT:    .long a
27entry:
28  %0 = load i32, i32* @a, align 4, !tbaa !2
29  %conv = sext i32 %0 to i64
30  %1 = inttoptr i64 %conv to i32*
31  %cmp = icmp eq i32* %1, %b
32  br i1 %cmp, label %if.then, label %if.end
33
34if.then:                                          ; preds = %entry
35  %call = tail call signext i32 bitcast (i32 (...)* @callVoid to i32 ()*)()
36  %call2 = tail call signext i32 @callNonVoid(i32* %b)
37  br label %if.end
38
39if.end:                                           ; preds = %if.then, %entry
40  %retval.0 = phi i32 [ %call2, %if.then ], [ undef, %entry ]
41  ret i32 %retval.0
42}
43
44declare signext i32 @callVoid(...) local_unnamed_addr
45
46declare signext i32 @callNonVoid(i32*) local_unnamed_addr
47
48define dso_local signext i32 @test2(i32* %p1) local_unnamed_addr  {
49; CHECK-LABEL: test2:
50; CHECK:       @ %bb.0: @ %entry
51; CHECK-NEXT:    push {r4, lr}
52; CHECK-NEXT:    cmp r0, #0
53; CHECK-NEXT:    beq .LBB1_2
54; CHECK-NEXT:  @ %bb.1: @ %if.end
55; CHECK-NEXT:    mov r4, r0
56; CHECK-NEXT:    ldr r0, .LCPI1_0
57; CHECK-NEXT:    ldr r0, [r0]
58; CHECK-NEXT:    cmp r0, r4
59; CHECK-NEXT:    beq .LBB1_3
60; CHECK-NEXT:  .LBB1_2: @ %return
61; CHECK-NEXT:    mov r0, #0
62; CHECK-NEXT:    pop {r4, lr}
63; CHECK-NEXT:    mov pc, lr
64; CHECK-NEXT:  .LBB1_3: @ %if.then2
65; CHECK-NEXT:    bl callVoid
66; CHECK-NEXT:    mov r0, r4
67; CHECK-NEXT:    pop {r4, lr}
68; CHECK-NEXT:    b callNonVoid
69; CHECK-NEXT:    .p2align 2
70; CHECK-NEXT:  @ %bb.4:
71; CHECK-NEXT:  .LCPI1_0:
72; CHECK-NEXT:    .long a
73entry:
74  %tobool = icmp eq i32* %p1, null
75  br i1 %tobool, label %return, label %if.end
76
77if.end:                                           ; preds = %entry
78  %0 = load i32, i32* @a, align 4, !tbaa !2
79  %conv = sext i32 %0 to i64
80  %1 = inttoptr i64 %conv to i32*
81  %cmp = icmp eq i32* %1, %p1
82  br i1 %cmp, label %if.then2, label %return
83
84if.then2:                                         ; preds = %if.end
85  %call = tail call signext i32 bitcast (i32 (...)* @callVoid to i32 ()*)()
86  %call3 = tail call signext i32 @callNonVoid(i32* nonnull %p1)
87  br label %return
88
89return:                                           ; preds = %if.end, %entry, %if.then2
90  %retval.0 = phi i32 [ %call3, %if.then2 ], [ 0, %entry ], [ 0, %if.end ]
91  ret i32 %retval.0
92}
93
94
95define dso_local i8* @test3(i8** nocapture %p1, i8 zeroext %p2) local_unnamed_addr  {
96; CHECK-LABEL: test3:
97; CHECK:       @ %bb.0: @ %entry
98; CHECK-NEXT:    push {r4, r5, r11, lr}
99; CHECK-NEXT:    ldr r4, [r0]
100; CHECK-NEXT:    cmp r4, #0
101; CHECK-NEXT:    beq .LBB2_2
102; CHECK-NEXT:  @ %bb.1: @ %land.rhs
103; CHECK-NEXT:    mov r5, r0
104; CHECK-NEXT:    mov r0, r4
105; CHECK-NEXT:    bl bar
106; CHECK-NEXT:    str r0, [r5]
107; CHECK-NEXT:  .LBB2_2: @ %land.end
108; CHECK-NEXT:    mov r0, r4
109; CHECK-NEXT:    pop {r4, r5, r11, lr}
110; CHECK-NEXT:    mov pc, lr
111entry:
112  %0 = load i8*, i8** %p1, align 8, !tbaa !6
113  %tobool = icmp eq i8* %0, null
114  br i1 %tobool, label %land.end, label %land.rhs
115
116land.rhs:                                         ; preds = %entry
117  %call = tail call i8* @bar(i8* nonnull %0, i8 zeroext %p2)
118  store i8* %call, i8** %p1, align 8, !tbaa !6
119  br label %land.end
120
121land.end:                                         ; preds = %entry, %land.rhs
122  ret i8* %0
123}
124
125declare i8* @bar(i8*, i8 zeroext) local_unnamed_addr
126
127
128!llvm.module.flags = !{!0}
129!llvm.ident = !{!1}
130
131!0 = !{i32 1, !"wchar_size", i32 4}
132!1 = !{!"clang version 10.0.0 (trunk 367381) (llvm/trunk 367388)"}
133!2 = !{!3, !3, i64 0}
134!3 = !{!"int", !4, i64 0}
135!4 = !{!"omnipotent char", !5, i64 0}
136!5 = !{!"Simple C/C++ TBAA"}
137!6 = !{!7, !7, i64 0}
138!7 = !{!"any pointer", !4, i64 0}
139