1 # RUN: llc -march=amdgcn -run-pass si-fold-operands -verify-machineinstrs %s -o - | FileCheck -check-prefix=GCN %s
3 # GCN-LABEL: name: fold-imm-copy
4 # GCN: [[SREG:%[0-9]+]]:sreg_32_xm0 = S_MOV_B32 65535
5 # GCN: V_AND_B32_e32 [[SREG]]
9 tracksRegLiveness: true
12 liveins: $vgpr0, $sgpr0_sgpr1
13 %0:vgpr_32 = COPY $vgpr0
14 %1:sgpr_64 = COPY $sgpr0_sgpr1
15 %2:sgpr_128 = S_LOAD_DWORDX4_IMM %1, 9, 0
16 %3:sreg_32_xm0 = S_MOV_B32 2
17 %4:vgpr_32 = V_LSHLREV_B32_e64 killed %3, %0, implicit $exec
18 %5:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
19 %6:vreg_64 = REG_SEQUENCE killed %4, %subreg.sub0, killed %5, %subreg.sub1
20 %7:vgpr_32 = BUFFER_LOAD_DWORD_ADDR64 %6, %2, 0, 4, 0, 0, implicit $exec
21 %8:sreg_32_xm0 = S_MOV_B32 65535
23 %10:vgpr_32 = V_AND_B32_e32 %7, %9, implicit $exec
27 # GCN-LABEL: name: no_extra_fold_on_same_opnd
28 # The first XOR needs commuting to fold that immediate operand.
29 # GCN: V_XOR_B32_e32 0, %1
30 # GCN: V_XOR_B32_e32 %2, %4.sub0
31 name: no_extra_fold_on_same_opnd
32 tracksRegLiveness: true
35 %0:vgpr_32 = IMPLICIT_DEF
36 %1:vgpr_32 = IMPLICIT_DEF
37 %2:vgpr_32 = IMPLICIT_DEF
38 %3:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
39 %4:vreg_64 = REG_SEQUENCE killed %0, %subreg.sub0, killed %3, %subreg.sub1
40 %5:vgpr_32 = V_XOR_B32_e32 %1, %4.sub1, implicit $exec
41 %6:vgpr_32 = V_XOR_B32_e32 %2, %4.sub0, implicit $exec
46 # Make sure the subreg index is not reinterpreted when folding
49 # GCN-LABEL: name: clear_subreg_imm_fold{{$}}
50 # GCN: %1:sgpr_32 = S_MOV_B32 4294967288
51 # GCN: %2:sgpr_32 = S_MOV_B32 4294967295
52 name: clear_subreg_imm_fold
53 tracksRegLiveness: true
56 %0:sreg_64 = S_MOV_B64 -8
57 %1:sgpr_32 = COPY %0.sub0
58 %2:sgpr_32 = COPY %0.sub1
59 S_ENDPGM 0, implicit %1, implicit %2
63 # GCN-LABEL: name: no_fold_imm_into_m0{{$}}
64 # GCN: %0:sreg_32 = S_MOV_B32 -8
65 # GCN-NEXT: $m0 = COPY %0
68 name: no_fold_imm_into_m0
69 tracksRegLiveness: true
72 %0:sreg_32 = S_MOV_B32 -8
74 S_ENDPGM 0, implicit $m0
78 # GCN-LABEL: name: fold_sgpr_imm_to_vgpr_copy{{$}}
79 # GCN: $vgpr0 = V_MOV_B32_e32 -8, implicit $exec
81 name: fold_sgpr_imm_to_vgpr_copy
82 tracksRegLiveness: true
85 %0:sreg_32 = S_MOV_B32 -8
87 S_ENDPGM 0, implicit $vgpr0
91 # The users of $vgpr1 should not be visited for further immediate
94 # GCN-LABEL: name: no_fold_physreg_users_vgpr{{$}}
95 # GCN: $vgpr1 = V_MOV_B32_e32 0, implicit $exec
96 # GCN-NEXT: S_NOP 0, implicit-def $vgpr1
97 # GCN-NEXT: %2:vgpr_32 = COPY $vgpr1
98 # GCN-NEXT: $vgpr2 = COPY %2
100 name: no_fold_physreg_users_vgpr
101 tracksRegLiveness: true
104 %0:sreg_32 = S_MOV_B32 0
107 S_NOP 0, implicit-def $vgpr1
108 %2:vgpr_32 = COPY $vgpr1