1 # RUN: llc -march=amdgcn -mcpu=gfx1010 -mattr=-wavefrontsize32,+wavefrontsize64 -run-pass=si-optimize-exec-masking -verify-machineinstrs %s -o - | FileCheck --check-prefixes=GCN,GFX1010 %s
2 # RUN: llc -march=amdgcn -mcpu=gfx1030 -mattr=-wavefrontsize32,+wavefrontsize64 -run-pass=si-optimize-exec-masking -verify-machineinstrs %s -o - | FileCheck --check-prefixes=GCN,GFX1030 %s
5 # After the Optimize exec masking (post-RA) pass, there's a change of having v_cmpx instructions
6 # being introduced whenever there's a sequence of v_cmp and s_and_saveexec instructions
7 # which can be safely replaced in various cases.
8 # However, it is not safe to do so when the generated code sequence would omit part of the EXEC mask
9 # which could occur when a subset of EXEC is used as input operand in the v_cmp instruction.
10 # The idea behind this test is to check if the subregisters are correctly handled here.
12 # GCN-LABEL: name: vcmp_saveexec_to_mov_vcmpx_exec_subreg
13 # GCN: V_CMP_GT_U32_e64
14 # GCN: S_AND_SAVEEXEC_B64
15 name: vcmp_saveexec_to_mov_vcmpx_exec_subreg
16 tracksRegLiveness: true
19 liveins: $vgpr0, $sgpr2
20 renamable $sgpr0_sgpr1 = V_CMP_GT_U32_e64 $sgpr2, killed $vgpr0, implicit $exec
21 $sgpr2_sgpr3 = COPY $exec, implicit-def $exec
22 $sgpr2_sgpr3 = S_AND_B64 killed renamable $sgpr2_sgpr3, killed renamable $sgpr0_sgpr1, implicit-def dead $scc
23 $exec = S_MOV_B64_term killed renamable $sgpr2_sgpr3
28 # Ensure the transformation does not get applied when the v_cmp target is used before the s_and_saveexec instruction.
30 # GCN-LABEL: name: vcmp_saveexec_to_mov_vcmpx_exec_intermediate_use
31 # GCN: V_CMP_LT_F32_e64
32 # GCN: V_WRITELANE_B32
33 # GCN: S_AND_SAVEEXEC_B64
34 name: vcmp_saveexec_to_mov_vcmpx_exec_intermediate_use
35 tracksRegLiveness: true
38 liveins: $vgpr0, $vgpr1, $sgpr2
39 renamable $sgpr0_sgpr1 = V_CMP_LT_F32_e64 0, 953267991, 2, $vgpr1, 0, implicit $mode, implicit $exec
40 $vgpr0 = V_WRITELANE_B32 0, $sgpr0, $vgpr0
41 $sgpr2_sgpr3 = COPY $exec, implicit-def $exec
42 $sgpr2_sgpr3 = S_AND_B64 killed renamable $sgpr2_sgpr3, killed renamable $sgpr0_sgpr1, implicit-def dead $scc
43 $exec = S_MOV_B64_term killed renamable $sgpr2_sgpr3
48 # Check if the modifiers are preserved when generating the V_CMPX instruction.
50 # GCN-LABEL: name: vcmp_saveexec_to_mov_vcmpx_check_abs
51 # GFX1010: V_CMP_LT_F32_e64
52 # GFX1010: S_AND_SAVEEXEC_B64
54 # GFX1030-NEXT: V_CMPX_LT_F32_nosdst_e64 0, 953267991, 2
55 name: vcmp_saveexec_to_mov_vcmpx_check_abs
56 tracksRegLiveness: true
60 renamable $sgpr0_sgpr1 = V_CMP_LT_F32_e64 0, 953267991, 2, $vgpr0, 0, implicit $mode, implicit $exec
61 $sgpr2_sgpr3 = COPY $exec, implicit-def $exec
62 $sgpr2_sgpr3 = S_AND_B64 killed renamable $sgpr2_sgpr3, killed renamable $sgpr0_sgpr1, implicit-def dead $scc
63 $exec = S_MOV_B64_term killed renamable $sgpr2_sgpr3
68 # Check if the sequence will be optimized even with more than 5 (unrelated) instructions inbetween the v_cmp and s_and_saveexec.
70 # GCN-LABEL: name: vcmp_saveexec_to_mov_vcmpx_check_many_instrs
71 # GFX1010: V_CMP_LT_F32_e64
72 # GFX1010: S_AND_SAVEEXEC_B64
74 # GFX1030: V_CMPX_LT_F32_nosdst_e64 0, 953267991, 2
75 name: vcmp_saveexec_to_mov_vcmpx_check_many_instrs
76 tracksRegLiveness: true
79 liveins: $vgpr0, $sgpr2, $vgpr1
80 renamable $sgpr0_sgpr1 = V_CMP_LT_F32_e64 0, 953267991, 2, $vgpr0, 0, implicit $mode, implicit $exec
81 $vgpr1 = V_WRITELANE_B32 0, $sgpr2, $vgpr1
82 $vgpr1 = V_WRITELANE_B32 0, $sgpr2, $vgpr1
83 $vgpr1 = V_WRITELANE_B32 0, $sgpr2, $vgpr1
84 $vgpr1 = V_WRITELANE_B32 0, $sgpr2, $vgpr1
85 $vgpr1 = V_WRITELANE_B32 0, $sgpr2, $vgpr1
86 $vgpr1 = V_WRITELANE_B32 0, $sgpr2, $vgpr1
87 $sgpr2_sgpr3 = COPY $exec, implicit-def $exec
88 $sgpr2_sgpr3 = S_AND_B64 killed renamable $sgpr2_sgpr3, killed renamable $sgpr0_sgpr1, implicit-def dead $scc
89 $exec = S_MOV_B64_term killed renamable $sgpr2_sgpr3