1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN %s
4 ; The first load produces address in a VGPR which is used in address calculation
5 ; of the second load (one inside the loop). The value is uniform and the inner
6 ; load correctly selected to use SADDR form, however the address is promoted to
7 ; vector registers because it all starts with a VGPR produced by the entry block
10 ; Check that we are changing SADDR form of a load to VADDR and do not have to use
11 ; readfirstlane instructions to move address from VGPRs into SGPRs.
13 define amdgpu_kernel void @test_move_load_address_to_vgpr(ptr addrspace(1) nocapture %arg) {
14 ; GCN-LABEL: test_move_load_address_to_vgpr:
16 ; GCN-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x24
17 ; GCN-NEXT: v_mov_b32_e32 v1, 0
18 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
19 ; GCN-NEXT: global_load_dword v0, v1, s[0:1] glc
20 ; GCN-NEXT: s_waitcnt vmcnt(0)
21 ; GCN-NEXT: v_mov_b32_e32 v3, s1
22 ; GCN-NEXT: v_add_u32_e32 v2, 0xffffff00, v0
23 ; GCN-NEXT: v_lshlrev_b64 v[0:1], 2, v[0:1]
24 ; GCN-NEXT: v_add_co_u32_e32 v0, vcc, s0, v0
25 ; GCN-NEXT: v_addc_co_u32_e32 v1, vcc, v3, v1, vcc
26 ; GCN-NEXT: .LBB0_1: ; %bb3
27 ; GCN-NEXT: ; =>This Inner Loop Header: Depth=1
28 ; GCN-NEXT: global_load_dword v3, v[0:1], off glc
29 ; GCN-NEXT: s_waitcnt vmcnt(0)
30 ; GCN-NEXT: v_add_co_u32_e32 v2, vcc, 1, v2
31 ; GCN-NEXT: v_add_co_u32_e64 v0, s[0:1], 4, v0
32 ; GCN-NEXT: v_addc_co_u32_e64 v1, s[0:1], 0, v1, s[0:1]
33 ; GCN-NEXT: s_and_b64 vcc, exec, vcc
34 ; GCN-NEXT: s_cbranch_vccz .LBB0_1
35 ; GCN-NEXT: ; %bb.2: ; %bb2
38 %i2 = load volatile i32, ptr addrspace(1) %arg, align 4
44 bb3: ; preds = %bb3, %bb
45 %i = phi i32 [ %i2, %bb ], [ %i8, %bb3 ]
46 %i4 = zext i32 %i to i64
47 %i5 = getelementptr inbounds i32, ptr addrspace(1) %arg, i64 %i4
48 %i6 = load volatile i32, ptr addrspace(1) %i5, align 4
49 %i8 = add nuw nsw i32 %i, 1
50 %i9 = icmp eq i32 %i8, 256
51 br i1 %i9, label %bb2, label %bb3
54 define amdgpu_kernel void @test_move_load_address_to_vgpr_d16_hi(ptr addrspace(1) nocapture %arg) {
55 ; GCN-LABEL: test_move_load_address_to_vgpr_d16_hi:
57 ; GCN-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x24
58 ; GCN-NEXT: v_mov_b32_e32 v1, 0
59 ; GCN-NEXT: s_movk_i32 s2, 0x100
60 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
61 ; GCN-NEXT: global_load_ushort v0, v1, s[0:1] glc
62 ; GCN-NEXT: s_waitcnt vmcnt(0)
63 ; GCN-NEXT: .LBB1_1: ; %bb3
64 ; GCN-NEXT: ; =>This Inner Loop Header: Depth=1
65 ; GCN-NEXT: s_waitcnt vmcnt(0)
66 ; GCN-NEXT: v_lshlrev_b64 v[2:3], 1, v[0:1]
67 ; GCN-NEXT: v_mov_b32_e32 v0, s1
68 ; GCN-NEXT: v_add_co_u32_e32 v2, vcc, s0, v2
69 ; GCN-NEXT: v_addc_co_u32_e32 v3, vcc, v0, v3, vcc
70 ; GCN-NEXT: global_load_short_d16_hi v0, v[2:3], off glc
71 ; GCN-NEXT: s_waitcnt vmcnt(0)
72 ; GCN-NEXT: v_cmp_eq_u32_e32 vcc, s2, v0
73 ; GCN-NEXT: s_cbranch_vccz .LBB1_1
74 ; GCN-NEXT: ; %bb.2: ; %bb2
77 %load.pre = load volatile i16, ptr addrspace(1) %arg, align 4
78 %i2 = zext i16 %load.pre to i32
84 bb3: ; preds = %bb3, %bb
85 %i = phi i32 [ %i2, %bb ], [ %i8, %bb3 ]
86 %i4 = zext i32 %i to i64
87 %i5 = getelementptr inbounds i16, ptr addrspace(1) %arg, i64 %i4
88 %i6 = load volatile i16, ptr addrspace(1) %i5, align 4
89 %insertelt = insertelement <2 x i16> undef, i16 %i6, i32 1
90 %i8 = bitcast <2 x i16> %insertelt to i32
91 %i9 = icmp eq i32 %i8, 256
92 br i1 %i9, label %bb2, label %bb3