1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck %s
3 ; RUN: llc -march=amdgcn -verify-machineinstrs -early-live-intervals < %s | FileCheck %s
5 ; We may have subregister live ranges that are undefined on some paths. The
6 ; verifier should not complain about this.
8 define amdgpu_kernel void @func() #0 {
10 ; CHECK: ; %bb.0: ; %B0
11 ; CHECK-NEXT: s_mov_b32 s0, 0
12 ; CHECK-NEXT: s_cbranch_scc1 .LBB0_2
13 ; CHECK-NEXT: ; %bb.1: ; %B30.1
14 ; CHECK-NEXT: s_mov_b32 s0, 0x7fc00000
15 ; CHECK-NEXT: .LBB0_2: ; %B30.2
16 ; CHECK-NEXT: v_mov_b32_e32 v0, s0
17 ; CHECK-NEXT: s_mov_b32 m0, -1
18 ; CHECK-NEXT: ds_write_b32 v0, v0
19 ; CHECK-NEXT: s_endpgm
21 br i1 undef, label %B1, label %B2
27 %v0 = phi <4 x float> [ zeroinitializer, %B1 ], [ <float 0.0, float 0.0, float 0.0, float undef>, %B0 ]
28 br i1 undef, label %B30.1, label %B30.2
31 %sub = fsub <4 x float> %v0, undef
35 %v3 = phi <4 x float> [ %sub, %B30.1 ], [ %v0, %B2 ]
36 %ve0 = extractelement <4 x float> %v3, i32 0
37 store float %ve0, ptr addrspace(3) undef, align 4
41 ; FIXME: Extra undef subregister copy should be removed before
42 ; overwritten with defined copy
43 define amdgpu_ps float @valley_partially_undef_copy() #0 {
44 ; CHECK-LABEL: valley_partially_undef_copy:
45 ; CHECK: ; %bb.0: ; %bb
46 ; CHECK-NEXT: s_mov_b32 s3, 0xf000
47 ; CHECK-NEXT: s_mov_b32 s2, -1
48 ; CHECK-NEXT: buffer_load_dword v1, off, s[0:3], 0 glc
49 ; CHECK-NEXT: s_waitcnt vmcnt(0)
50 ; CHECK-NEXT: buffer_load_dword v0, off, s[0:3], 0 glc
51 ; CHECK-NEXT: s_waitcnt vmcnt(0)
52 ; CHECK-NEXT: v_mov_b32_e32 v2, 0x7fc00000
53 ; CHECK-NEXT: buffer_store_dwordx4 v[0:3], off, s[0:3], 0
54 ; CHECK-NEXT: buffer_store_dword v2, off, s[0:3], 0
55 ; CHECK-NEXT: v_cmp_ne_u32_e32 vcc, 0, v1
56 ; CHECK-NEXT: s_waitcnt expcnt(1)
57 ; CHECK-NEXT: v_cndmask_b32_e64 v1, 0, 1, vcc
58 ; CHECK-NEXT: v_cmp_ne_u32_e64 s[0:1], 1, v1
59 ; CHECK-NEXT: .LBB1_1: ; %bb9
60 ; CHECK-NEXT: ; =>This Inner Loop Header: Depth=1
61 ; CHECK-NEXT: s_and_b64 vcc, exec, s[0:1]
62 ; CHECK-NEXT: s_cbranch_vccnz .LBB1_1
63 ; CHECK-NEXT: ; %bb.2: ; %bb11
64 ; CHECK-NEXT: s_mov_b32 s3, 0xf000
65 ; CHECK-NEXT: s_mov_b32 s2, -1
66 ; CHECK-NEXT: buffer_store_dwordx4 v[0:3], off, s[0:3], 0
67 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0)
68 ; CHECK-NEXT: ; return to shader part epilog
70 %tmp = load volatile i32, ptr addrspace(1) undef, align 4
71 %tmp1 = load volatile i32, ptr addrspace(1) undef, align 4
72 %tmp2 = insertelement <4 x i32> undef, i32 %tmp1, i32 0
73 %tmp3 = bitcast i32 %tmp1 to float
74 %tmp4 = call <4 x float> @llvm.amdgcn.image.sample.2d.v4f32.f32(i32 15, float %tmp3, float %tmp3, <8 x i32> undef, <4 x i32> undef, i1 0, i32 0, i32 0)
75 %tmp5 = extractelement <4 x float> %tmp4, i32 0
76 %tmp6 = fmul float %tmp5, undef
77 %tmp7 = fadd float %tmp6, %tmp6
78 %tmp8 = insertelement <4 x i32> %tmp2, i32 %tmp, i32 1
79 store <4 x i32> %tmp8, ptr addrspace(1) undef, align 16
80 store float %tmp7, ptr addrspace(1) undef, align 4
83 bb9: ; preds = %bb9, %bb
84 %tmp10 = icmp eq i32 %tmp, 0
85 br i1 %tmp10, label %bb9, label %bb11
88 store <4 x i32> %tmp2, ptr addrspace(1) undef, align 16
92 ; FIXME: Should be able to remove the undef copies
93 define amdgpu_kernel void @partially_undef_copy() #0 {
94 ; CHECK-LABEL: partially_undef_copy:
96 ; CHECK-NEXT: ;;#ASMSTART
97 ; CHECK-NEXT: v_mov_b32_e32 v5, 5
98 ; CHECK-NEXT: ;;#ASMEND
99 ; CHECK-NEXT: ;;#ASMSTART
100 ; CHECK-NEXT: v_mov_b32_e32 v6, 6
101 ; CHECK-NEXT: ;;#ASMEND
102 ; CHECK-NEXT: v_mov_b32_e32 v0, v5
103 ; CHECK-NEXT: v_mov_b32_e32 v1, v6
104 ; CHECK-NEXT: v_mov_b32_e32 v2, v7
105 ; CHECK-NEXT: v_mov_b32_e32 v3, v8
106 ; CHECK-NEXT: s_mov_b32 s3, 0xf000
107 ; CHECK-NEXT: s_mov_b32 s2, -1
108 ; CHECK-NEXT: v_mov_b32_e32 v0, v6
109 ; CHECK-NEXT: buffer_store_dwordx4 v[0:3], off, s[0:3], 0
110 ; CHECK-NEXT: s_waitcnt vmcnt(0)
111 ; CHECK-NEXT: ;;#ASMSTART
113 ; CHECK-NEXT: ;;#ASMEND
114 ; CHECK-NEXT: s_endpgm
115 %tmp0 = call i32 asm sideeffect "v_mov_b32_e32 v5, 5", "={v5}"()
116 %tmp1 = call i32 asm sideeffect "v_mov_b32_e32 v6, 6", "={v6}"()
118 %partially.undef.0 = insertelement <4 x i32> undef, i32 %tmp0, i32 0
119 %partially.undef.1 = insertelement <4 x i32> %partially.undef.0, i32 %tmp1, i32 0
121 store volatile <4 x i32> %partially.undef.1, ptr addrspace(1) undef, align 16
122 tail call void asm sideeffect "v_nop", "v={v[5:8]}"(<4 x i32> %partially.undef.0)
126 declare <4 x float> @llvm.amdgcn.image.sample.2d.v4f32.f32(i32, float, float, <8 x i32>, <4 x i32>, i1, i32, i32) #1
128 attributes #0 = { nounwind }
129 attributes #1 = { nounwind readonly }