xref: /llvm-project/llvm/test/CodeGen/AMDGPU/fix-frame-ptr-reg-copy-livein.ll (revision 9e9907f1cfa424366fba58d9520f9305b537cec9)
1; RUN: llc -mtriple=amdgcn -mcpu=gfx900 -stop-after=prologepilog -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
2
3; It is a small loop test that iterates over the array member of the structure argument  passed byval to the function.
4; The loop code will keep the prologue and epilogue blocks apart.
5; The test is primarily to check the temp register used to preserve the earlier FP value
6; is live-in at every BB in the function.
7
8%struct.Data = type { [20 x i32] }
9
10define i32 @fp_save_restore_in_temp_sgpr(ptr addrspace(5) nocapture readonly byval(%struct.Data) align 4 %arg) #0 {
11  ; GCN-LABEL: name: fp_save_restore_in_temp_sgpr
12  ; GCN: bb.0.begin:
13  ; GCN:   liveins: $sgpr11
14  ; GCN:   $sgpr11 = frame-setup COPY $sgpr33
15  ; GCN:   $sgpr33 = frame-setup COPY $sgpr32
16  ; GCN: bb.1.lp_end:
17  ; GCN:   liveins: $sgpr10, $sgpr11, $vgpr1, $sgpr4_sgpr5, $sgpr6_sgpr7, $sgpr8_sgpr9
18  ; GCN: bb.2.lp_begin:
19  ; GCN:   liveins: $sgpr10, $sgpr11, $vgpr1, $sgpr4_sgpr5, $sgpr6_sgpr7
20  ; GCN: bb.3.Flow:
21  ; GCN:   liveins: $sgpr10, $sgpr11, $vgpr0, $vgpr1, $sgpr4_sgpr5, $sgpr6_sgpr7, $sgpr8_sgpr9
22  ; GCN: bb.4.end:
23  ; GCN:   liveins: $sgpr11, $vgpr0, $sgpr4_sgpr5
24  ; GCN:   $sgpr33 = frame-destroy COPY $sgpr11
25begin:
26  br label %lp_begin
27
28lp_end:                                                ; preds = %lp_begin
29  %cur_idx = add nuw nsw i32 %idx, 1
30  %lp_term_cond = icmp eq i32 %cur_idx, 20
31  br i1 %lp_term_cond, label %end, label %lp_begin
32
33lp_begin:                                                ; preds = %lp_end, %begin
34  %idx = phi i32 [ 0, %begin ], [ %cur_idx, %lp_end ]
35  %ptr = getelementptr inbounds %struct.Data, ptr addrspace(5) %arg, i32 0, i32 0, i32 %idx
36  %data = load i32, ptr addrspace(5) %ptr, align 4
37  %data_cmp = icmp eq i32 %data, %idx
38  br i1 %data_cmp, label %lp_end, label %end
39
40end:                                               ; preds = %lp_end, %lp_begin
41  %ret_val = phi i32 [ 0, %lp_begin ], [ 1, %lp_end ]
42  ret i32 %ret_val
43}
44
45attributes #0 = { norecurse nounwind "frame-pointer"="all" }
46