1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=powerpc64le-- -verify-machineinstrs | FileCheck %s
3 ; RUN: llc < %s -mtriple=powerpc64-- -verify-machineinstrs | FileCheck %s \
4 ; RUN: --check-prefix=BE
5 %struct.__jmp_buf_tag = type { [64 x i64], i32, %struct.__sigset_t, [8 x i8] }
6 %struct.__sigset_t = type { [16 x i64] }
8 @.str = private unnamed_addr constant [33 x i8] c"Successfully returned from main\0A\00", align 1
10 ; Function Attrs: nounwind
11 define dso_local signext i32 @main(i32 signext %argc, ptr nocapture readnone %argv) local_unnamed_addr #0 {
13 ; CHECK: # %bb.0: # %entry
14 ; CHECK-NEXT: mfocrf 12, 32
15 ; CHECK-NEXT: std 31, -8(1)
16 ; CHECK-NEXT: stw 12, 8(1)
18 ; CHECK-NEXT: stdu 1, -784(1)
19 ; CHECK-NEXT: # kill: def $r3 killed $r3 killed $x3
20 ; CHECK-NEXT: cmpwi 2, 3, 2
22 ; CHECK-NEXT: std 0, 800(1)
23 ; CHECK-NEXT: mr 31, 1
25 ; CHECK-NEXT: blt 2, .LBB0_3
26 ; CHECK-NEXT: # %bb.1: # %if.end
27 ; CHECK-NEXT: addi 3, 31, 112
28 ; CHECK-NEXT: bl _setjmp
30 ; CHECK-NEXT: # kill: def $r3 killed $r3 killed $x3
31 ; CHECK-NEXT: cmpwi 3, 0
32 ; CHECK-NEXT: crmove 20, 10
33 ; CHECK-NEXT: crorc 20, 10, 2
34 ; CHECK-NEXT: crmove 21, 2
35 ; CHECK-NEXT: bc 4, 20, .LBB0_4
36 ; CHECK-NEXT: # %bb.2: # %if.end5
37 ; CHECK-NEXT: addis 3, 2, .L.str@toc@ha
38 ; CHECK-NEXT: addi 3, 3, .L.str@toc@l
39 ; CHECK-NEXT: bl printf
41 ; CHECK-NEXT: # kill: def $r3 killed $r3 killed $x3
42 ; CHECK-NEXT: .LBB0_3: # %return
43 ; CHECK-NEXT: # kill: def $r3 killed $r3 def $x3
44 ; CHECK-NEXT: addi 1, 31, 784
45 ; CHECK-NEXT: ld 0, 16(1)
46 ; CHECK-NEXT: lwz 12, 8(1)
47 ; CHECK-NEXT: ld 31, -8(1)
49 ; CHECK-NEXT: mtocrf 32, 12
51 ; CHECK-NEXT: .LBB0_4: # %if.then3
52 ; CHECK-NEXT: ld 4, 0(1)
53 ; CHECK-NEXT: stdu 4, -16(1)
54 ; CHECK-NEXT: addi 3, 1, 96
55 ; CHECK-NEXT: li 4, -1
56 ; CHECK-NEXT: stb 4, 0(3)
57 ; CHECK-NEXT: addi 4, 31, 112
62 ; BE: # %bb.0: # %entry
65 ; BE-NEXT: std 31, -8(1)
66 ; BE-NEXT: stw 12, 8(1)
67 ; BE-NEXT: stdu 1, -800(1)
69 ; BE-NEXT: # kill: def $r3 killed $r3 killed $x3
70 ; BE-NEXT: cmpwi 2, 3, 2
72 ; BE-NEXT: std 0, 816(1)
74 ; BE-NEXT: blt 2, .LBB0_3
75 ; BE-NEXT: # %bb.1: # %if.end
76 ; BE-NEXT: addi 3, 31, 128
79 ; BE-NEXT: crmove 20, 10
80 ; BE-NEXT: # kill: def $r3 killed $r3 killed $x3
82 ; BE-NEXT: crorc 20, 10, 2
83 ; BE-NEXT: crmove 21, 2
84 ; BE-NEXT: bc 4, 20, .LBB0_4
85 ; BE-NEXT: # %bb.2: # %if.end5
86 ; BE-NEXT: addis 3, 2, .L.str@toc@ha
87 ; BE-NEXT: addi 3, 3, .L.str@toc@l
90 ; BE-NEXT: # kill: def $r3 killed $r3 killed $x3
91 ; BE-NEXT: .LBB0_3: # %return
92 ; BE-NEXT: # kill: def $r3 killed $r3 def $x3
93 ; BE-NEXT: addi 1, 31, 800
94 ; BE-NEXT: ld 0, 16(1)
95 ; BE-NEXT: lwz 12, 8(1)
96 ; BE-NEXT: ld 31, -8(1)
98 ; BE-NEXT: mtcrf 32, 12 # cr2
100 ; BE-NEXT: .LBB0_4: # %if.then3
101 ; BE-NEXT: ld 4, 0(1)
102 ; BE-NEXT: stdu 4, -16(1)
103 ; BE-NEXT: addi 3, 1, 112
105 ; BE-NEXT: stb 4, 0(3)
106 ; BE-NEXT: addi 4, 31, 128
110 %env_buffer = alloca [1 x %struct.__jmp_buf_tag], align 16
111 %cmp = icmp slt i32 %argc, 2
112 br i1 %cmp, label %return, label %if.end
114 if.end: ; preds = %entry
115 call void @llvm.lifetime.start.p0(i64 656, ptr nonnull %env_buffer) #5
116 %call = call signext i32 @_setjmp(ptr nonnull %env_buffer) #6
117 %cmp1 = icmp ne i32 %argc, 2
118 %cmp2 = icmp eq i32 %call, 0
119 %or.cond = and i1 %cmp1, %cmp2
120 br i1 %or.cond, label %if.then3, label %if.end5
122 if.then3: ; preds = %if.end
123 %0 = alloca [8 x i8], align 16
124 store i8 -1, ptr %0, align 16
125 call void @test(ptr nonnull %0, ptr nonnull %env_buffer) #7
128 if.end5: ; preds = %if.end
129 %call6 = call signext i32 (ptr, ...) @printf(ptr nonnull dereferenceable(1) @.str)
130 call void @llvm.lifetime.end.p0(i64 656, ptr nonnull %env_buffer) #5
133 return: ; preds = %entry, %if.end5
134 %retval.0 = phi i32 [ %call6, %if.end5 ], [ 0, %entry ]
138 ; Function Attrs: argmemonly nofree nosync nounwind willreturn
139 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
141 ; Function Attrs: nounwind returns_twice
142 declare signext i32 @_setjmp(ptr) local_unnamed_addr
144 ; Function Attrs: noreturn
145 declare void @test(ptr, ptr) local_unnamed_addr
147 ; Function Attrs: nofree nounwind
148 declare noundef signext i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr
150 ; Function Attrs: argmemonly nofree nosync nounwind willreturn
151 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)
153 attributes #0 = { nounwind }
154 attributes #6 = { nounwind returns_twice }