1 # REQUIRES: amdgpu-registered-target
2 # RUN: llvm-reduce -abort-on-invalid-reduction -simplify-mir --delta-passes=register-defs -mtriple=amdgcn-amd-amdhsa --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS0,ALL --test-arg %s --test-arg --input-file %s -o %t 2> %t.log
3 # RUN: FileCheck --match-full-lines --check-prefixes=RESULT0,ALL %s < %t
5 # ALL-LABEL: name: func0
6 # CHECK-INTERESTINGNESS0: V_MUL_F32
8 # RESULT0: %mul1:vgpr_32 = IMPLICIT_DEF
9 # RESULT0-NOT: V_ADD_CO_U32
10 # RESULT0: %addco0:vgpr_32 = IMPLICIT_DEF
11 # RESULT0-NEXT: %addco1:sreg_64_xexec = IMPLICIT_DEF
12 # RESULT0-NOT: V_ADD_CO_U32
16 tracksRegLiveness: true
19 liveins: $vgpr0, $vgpr1
22 %vgpr0:vgpr_32 = COPY $vgpr0
23 %vgpr1:vgpr_32 = COPY $vgpr1
24 %mul0:vgpr_32 = V_MUL_F32_e32 %vgpr0, %vgpr1, implicit $mode, implicit $exec
25 %mul1:vgpr_32 = V_MUL_F32_e32 %vgpr1, %vgpr0, implicit $mode, implicit $exec
26 %addco0:vgpr_32, %addco1:sreg_64_xexec = V_ADD_CO_U32_e64 %vgpr0, %vgpr1, 0, implicit $exec
27 S_NOP 0, implicit %addco0
28 S_NOP 0, implicit %addco1
29 S_ENDPGM 0, implicit %mul0, implicit %mul1
32 # ALL-LABEL: name: subreg_def
33 # CHECK-INTERESTINGNESS0: %super.sub0
35 # RESULT0: undef %super.sub0:vreg_64 = IMPLICIT_DEF
36 # RESULT0-NEXT: %super.sub1:vreg_64 = IMPLICIT_DEF
39 tracksRegLiveness: true
42 liveins: $vgpr0, $vgpr1
44 %vgpr0:vgpr_32 = COPY $vgpr0
45 %vgpr1:vgpr_32 = COPY $vgpr1
46 undef %super.sub0:vreg_64 = IMPLICIT_DEF
47 %super.sub1:vreg_64 = V_ADD_F32_e32 %vgpr0, %vgpr1, implicit $mode, implicit $exec
49 S_NOP 0, implicit %super.sub0
50 S_ENDPGM 0, implicit %super.sub0
53 # Make sure we don't introduce multiple implicit_defs if an
54 # instruction has repeated, identical defs.
55 # ALL-LABEL: name: multi_def
56 # CHECK-INTERESTINGNESS0: S_NOP 2
58 # RESULT0: %redef:vgpr_32 = IMPLICIT_DEF
59 # RESULT0-NOT: %redef:vgpr_32 = IMPLICIT_DEF
62 tracksRegLiveness: true
65 liveins: $vgpr0, $vgpr1
67 %vgpr0:vgpr_32 = COPY $vgpr0
68 %vgpr1:vgpr_32 = COPY $vgpr1
69 S_NOP 1, implicit-def %redef:vgpr_32, implicit-def %redef:vgpr_32
70 S_NOP 2, implicit %redef
73 # ALL-LABEL: name: multi_def_keep_two
74 # CHECK-INTERESTINGNESS0: implicit-def %def0
75 # CHECK-INTERESTINGNESS0: implicit-def %def2
77 # RESULT0: %def1:vgpr_32 = IMPLICIT_DEF
78 # RESULT0-NEXT: S_NOP 1, implicit-def %def0, implicit-def %def2
79 # RESULT0-NEXT: S_NOP 2, implicit %def0, implicit %def1, implicit %def2
82 name: multi_def_keep_two
83 tracksRegLiveness: true
86 liveins: $vgpr0, $vgpr1
88 %vgpr0:vgpr_32 = COPY $vgpr0
89 %vgpr1:vgpr_32 = COPY $vgpr1
90 S_NOP 1, implicit-def %def0:vgpr_32, implicit-def %def1:vgpr_32, implicit-def %def2:vgpr_32
91 S_NOP 2, implicit %def0, implicit %def1, implicit %def2
94 # ALL-LABEL: name: multi_def_subreg
95 # CHECK-INTERESTINGNESS0: S_NOP 4
97 # RESULT0: undef %redef.sub0:vreg_64 = IMPLICIT_DEF
98 # RESULT0: undef %redef.sub1:vreg_64 = IMPLICIT_DEF
100 name: multi_def_subreg
101 tracksRegLiveness: true
104 liveins: $vgpr0, $vgpr1
106 %vgpr0:vgpr_32 = COPY $vgpr0
107 %vgpr1:vgpr_32 = COPY $vgpr1
108 S_NOP 3, undef implicit-def %redef.sub0:vreg_64, undef implicit-def %redef.sub1:vreg_64
109 S_NOP 4, implicit %redef
112 # ALL-LABEL: name: multi_def_subreg_same_subreg
113 # CHECK-INTERESTINGNESS0: S_NOP 4
115 # RESULT0-NOT: implicit-def %redef
116 # RESULT0: undef %redef.sub0:vreg_64 = IMPLICIT_DEF
117 # RESULT0-NOT: implicit-def %redef
119 name: multi_def_subreg_same_subreg
120 tracksRegLiveness: true
123 liveins: $vgpr0, $vgpr1
125 %vgpr0:vgpr_32 = COPY $vgpr0
126 %vgpr1:vgpr_32 = COPY $vgpr1
127 S_NOP 3, undef implicit-def %redef.sub0:vreg_64, undef implicit-def %redef.sub0:vreg_64
128 S_NOP 4, implicit %redef
131 # ALL-LABEL: name: tied_def
132 # CHECK-INTERESTINGNESS0: V_MAC_F32
134 # RESULT0: %mac0:vgpr_32 = V_MAC_F32_e32 %vgpr0, %vgpr1, undef %mac0, implicit $mode, implicit $exec
135 # RESULT0: %mac1:vgpr_32 = IMPLICIT_DEF
138 tracksRegLiveness: true
141 liveins: $vgpr0, $vgpr1
144 %vgpr0:vgpr_32 = COPY $vgpr0
145 %vgpr1:vgpr_32 = COPY $vgpr1
146 %mac0:vgpr_32 = V_MAC_F32_e32 %vgpr0, %vgpr1, undef %mac0, implicit $mode, implicit $exec
147 %mac1:vgpr_32 = V_MAC_F32_e32 %vgpr1, %vgpr0, %mac0, implicit $mode, implicit $exec
148 S_ENDPGM 0, implicit %mac0, implicit %mac1
151 # ALL-LABEL: name: generic_reg
152 # CHECK-INTERESTINGNESS0: %fmul:vgpr(s32) =
153 # RESULT0: %fmul:vgpr(s32) = G_IMPLICIT_DEF
156 tracksRegLiveness: true
159 liveins: $vgpr0, $vgpr1
161 %vgpr0:vgpr_32(s32) = COPY $vgpr0
162 %vgpr1:vgpr_32(s32) = COPY $vgpr1
163 %fmul:vgpr(s32) = G_FMUL %vgpr0, %vgpr1
164 S_ENDPGM 0, implicit %fmul
167 # ALL-LABEL: name: terminator_def
169 # CHECK-INTERESTINGNESS0: %exec_copy0:sreg_64_xexec = S_MOV_B64_term $exec
171 # RESULT0: %exec_copy0:sreg_64_xexec = S_MOV_B64_term $exec
172 # RESULT0-NEXT: %exec_copy1:sreg_64_xexec = S_MOV_B64_term $exec
173 # RESULT0-NEXT: S_CBRANCH_EXECZ %bb.2, implicit $exec
176 tracksRegLiveness: true
179 liveins: $sgpr8_sgpr9
181 %exec_copy0:sreg_64_xexec = S_MOV_B64_term $exec
182 %exec_copy1:sreg_64_xexec = S_MOV_B64_term $exec
183 S_CBRANCH_EXECZ %bb.2, implicit $exec
189 S_ENDPGM 0, implicit %exec_copy0, implicit %exec_copy1