[llvm] [AMDGPU] Use s_cmovk_i32 instead of s_cselect_b32 when applicable (PR #135232)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri May 2 08:00:07 PDT 2025


================
@@ -0,0 +1,35 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
+# RUN: llc -mtriple=amdgcn -mcpu=gfx900 -verify-machineinstrs -start-before si-shrink-instructions -stop-before si-post-ra-bundler -o - %s | FileCheck -check-prefix=GCN %s
+
+---
+name: shrink-select-hint
+tracksRegLiveness: true
+body:             |
+  bb.0:
+    ; GCN-LABEL: name: shrink-select-hint
+    ; GCN: renamable $sgpr0 = S_MOV_B32 0
+    ; GCN-NEXT: renamable $sgpr1 = S_MOV_B32 0
+    ; GCN-NEXT: renamable $sgpr2 = S_MOV_B32 0
+    ; GCN-NEXT: renamable $sgpr0 = S_ADD_U32 killed renamable $sgpr0, killed renamable $sgpr1, implicit-def $scc
+    ; GCN-NEXT: renamable $sgpr2 = S_CMOVK_I32 31744, implicit killed $scc
+    ; GCN-NEXT: S_ENDPGM 0, implicit killed renamable $sgpr2, implicit killed renamable $sgpr0
+    %0:sgpr_32 = S_MOV_B32 0
+    %1:sgpr_32 = S_MOV_B32 0
+    %2:sgpr_32 = S_MOV_B32 0
+    %3:sgpr_32 = S_ADD_U32 killed %0, %1, implicit-def $scc
+    %4:sgpr_32 = S_CSELECT_B32 %2, 31744, implicit $scc
+    S_ENDPGM 0, implicit %4, implicit %3
+...
+---
+name: shrink-select
+tracksRegLiveness: true
+body:             |
+  bb.0:
+    ; GCN-LABEL: name: shrink-select
+    ; GCN: renamable $sgpr0 = S_CMOVK_I32 31744, implicit undef $scc
+    ; GCN-NEXT: S_ENDPGM 0, implicit killed renamable $sgpr0
+    %0:sgpr_32 = IMPLICIT_DEF
+    $scc = IMPLICIT_DEF
+    %1:sgpr_32 = S_CSELECT_B32 %0, 31744, implicit $scc
+    S_ENDPGM 0, implicit %1
+...
----------------
arsenm wrote:

We don't use FP immediate, only ever use isImm 

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


More information about the llvm-commits mailing list