1 # RUN: llc -march=amdgcn -mcpu=gfx1010 -mattr=+wavefrontsize32 -run-pass=si-optimize-exec-masking -verify-machineinstrs %s -o - | FileCheck --check-prefixes=GCN,WAVE32 %s
2 # RUN: llc -march=amdgcn -mcpu=gfx1010 -mattr=-wavefrontsize32,+wavefrontsize64 -run-pass=si-optimize-exec-masking -verify-machineinstrs %s -o - | FileCheck --check-prefixes=GCN,WAVE64 %s
6 # After the Optimize exec masking (post-RA) pass, codegen can end up with the following sequence:
7 # s_or_saveexec_b32 s0, s0
8 # s_xor_b32 exec_lo, exec_lo, s0
10 # This can be combined into one instruction:
11 # s_andn2_saveexec_b32 s0, s0
13 # Ensure the transformation gets applied in the b32 case.
14 # GCN-LABEL: name: s_or_saveexec_xor_combine_b32
15 # WAVE32: S_ANDN2_SAVEEXEC_B32
16 name: s_or_saveexec_xor_combine_b32
17 tracksRegLiveness: true
21 renamable $sgpr0 = S_OR_SAVEEXEC_B32 killed renamable $sgpr0, implicit-def $exec, implicit-def $scc, implicit $exec
22 $exec_lo = S_XOR_B32 $exec_lo, renamable $sgpr0, implicit-def $scc
27 # Ensure the transformation gets applied in the b64 case.
28 # GCN-LABEL: name: s_or_saveexec_xor_combine_b64
29 # WAVE64: S_ANDN2_SAVEEXEC_B64
30 name: s_or_saveexec_xor_combine_b64
31 tracksRegLiveness: true
35 renamable $sgpr0_sgpr1 = S_OR_SAVEEXEC_B64 killed renamable $sgpr0_sgpr1, implicit-def $exec, implicit-def $scc, implicit $exec
36 $exec = S_XOR_B64 $exec, renamable $sgpr0_sgpr1, implicit-def $scc
41 # Ensure the transformation does get applied even if the operands are swapped.
42 # GCN-LABEL: name: s_or_saveexec_xor_combine_b32_swap
43 # WAVE32: S_ANDN2_SAVEEXEC_B32
44 name: s_or_saveexec_xor_combine_b32_swap
45 tracksRegLiveness: true
49 renamable $sgpr0 = S_OR_SAVEEXEC_B32 killed renamable $sgpr0, implicit-def $exec, implicit-def $scc, implicit $exec
50 $exec_lo = S_XOR_B32 renamable $sgpr0, $exec_lo, implicit-def $scc
55 # Ensure the transformation does get applied if source and dest operand for s_or_saveeexec are not equal.
56 # GCN-LABEL: name: s_or_saveexec_xor_combine_b32_inequal_operands
57 # WAVE32: S_ANDN2_SAVEEXEC
58 name: s_or_saveexec_xor_combine_b32_inequal_operands
59 tracksRegLiveness: true
62 liveins: $sgpr0, $sgpr1
63 renamable $sgpr0 = S_OR_SAVEEXEC_B32 killed renamable $sgpr1, implicit-def $exec, implicit-def $scc, implicit $exec
64 $exec_lo = S_XOR_B32 $exec_lo, renamable $sgpr0, implicit-def $scc
69 # Ensure the transformation does not get applied if s_xor does not use the dest as input operand.
70 # GCN-LABEL: name: s_or_saveexec_xor_combine_b32_wrong_input
71 # WAVE32: S_OR_SAVEEXEC
73 name: s_or_saveexec_xor_combine_b32_wrong_input
74 tracksRegLiveness: true
77 liveins: $sgpr0, $sgpr1
78 renamable $sgpr0 = S_OR_SAVEEXEC_B32 killed renamable $sgpr0, implicit-def $exec, implicit-def $scc, implicit $exec
79 $exec_lo = S_XOR_B32 $exec_lo, renamable $sgpr1, implicit-def $scc
85 # Ensure the transformation does not get applied if the instructions don't appear sequentially.
86 # GCN-LABEL: name: s_or_saveexec_xor_combine_b32_non_sequence
87 # WAVE32: S_OR_SAVEEXEC
90 name: s_or_saveexec_xor_combine_b32_non_sequence
91 tracksRegLiveness: true
94 liveins: $sgpr0, $sgpr1
95 renamable $sgpr0 = S_OR_SAVEEXEC_B32 killed renamable $sgpr0, implicit-def $exec, implicit-def $scc, implicit $exec
96 renamable $sgpr1 = S_MOV_B32 renamable $sgpr0
97 $exec_lo = S_XOR_B32 $exec_lo, renamable $sgpr1, implicit-def $scc
102 # Don't apply the transformation if the basic block only has a single instruction.
104 # GCN-LABEL: name: s_or_saveexec_xor_combine_b32_last_inst
105 # WAVE32: S_OR_SAVEEXEC
106 name: s_or_saveexec_xor_combine_b32_last_inst
107 tracksRegLiveness: true
111 renamable $sgpr0 = S_OR_SAVEEXEC_B32 killed renamable $sgpr0, implicit-def $exec, implicit-def $scc, implicit $exec
116 # Don't apply the transformation if the basic block ends with an S_OR_SAVEEXEC_B32 instruction.
118 # GCN-LABEL: name: s_or_saveexec_xor_combine_b32_or_saveexec_terminator
120 # WAVE32: S_OR_SAVEEXEC
121 name: s_or_saveexec_xor_combine_b32_or_saveexec_terminator
122 tracksRegLiveness: true
125 liveins: $sgpr0, $sgpr1
126 renamable $sgpr1 = S_MOV_B32 renamable $sgpr0
127 renamable $sgpr0 = S_OR_SAVEEXEC_B32 killed renamable $sgpr0, implicit-def $exec, implicit-def $scc, implicit $exec