[llvm] [AMDGPU] Insert readfirstlane in the function returns in sgpr. (PR #135326)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 21 04:17:04 PDT 2025


================
@@ -72,3 +72,76 @@ define amdgpu_ps ptr @uniform_v_to_s_ptr(ptr inreg %x) {
   %ptr = inttoptr i32 %int to ptr
   ret ptr %ptr
 }
+
+define amdgpu_ps half @uniform_v_to_s_f16(half inreg %a, half inreg %b) {
+; GFX11-LABEL: uniform_v_to_s_f16:
+; GFX11:       ; %bb.0:
+; GFX11-NEXT:    v_max_f16_e64 v0, s0, s1
+; GFX11-NEXT:    v_cmp_o_f16_e64 vcc_lo, s0, s1
+; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_2)
+; GFX11-NEXT:    v_cndmask_b32_e32 v0, 0x7e00, v0, vcc_lo
+; GFX11-NEXT:    ; return to shader part epilog
+  %max = call half @llvm.maximum.f16(half %a, half %b)
+  ret half %max
+}
----------------
arsenm wrote:

This does not use an SGPR return, there is no readfirstlane emitted. You need to use an integer type and bitcast 

https://github.com/llvm/llvm-project/pull/135326


More information about the llvm-commits mailing list