1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -march=amdgcn -mcpu=tahiti -run-pass=instruction-select -verify-machineinstrs -o - %s  | FileCheck -check-prefix=GFX6 %s
3# RUN: llc -march=amdgcn -mcpu=fiji -run-pass=instruction-select -verify-machineinstrs -o - %s  | FileCheck -check-prefix=GFX6 %s
4# RUN: llc -march=amdgcn -mcpu=gfx900 -run-pass=instruction-select -verify-machineinstrs -o - %s  | FileCheck -check-prefix=GFX9 %s
5
6---
7name:            add_s32
8legalized:       true
9regBankSelected: true
10
11body: |
12  bb.0:
13    liveins: $sgpr0, $sgpr1, $vgpr0, $vgpr3_vgpr4
14
15
16    ; GFX6-LABEL: name: add_s32
17    ; GFX6: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
18    ; GFX6: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
19    ; GFX6: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr0
20    ; GFX6: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 [[COPY]], [[COPY1]], implicit-def $scc
21    ; GFX6: %7:vgpr_32, dead %12:sreg_64_xexec = V_ADD_I32_e64 [[COPY2]], [[S_ADD_I32_]], 0, implicit $exec
22    ; GFX6: %8:vgpr_32, dead %11:sreg_64_xexec = V_ADD_I32_e64 [[S_ADD_I32_]], %7, 0, implicit $exec
23    ; GFX6: %9:vgpr_32, dead %10:sreg_64_xexec = V_ADD_I32_e64 %8, [[COPY2]], 0, implicit $exec
24    ; GFX6: S_ENDPGM 0, implicit [[S_ADD_I32_]], implicit %7, implicit %8, implicit %9
25    ; GFX9-LABEL: name: add_s32
26    ; GFX9: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
27    ; GFX9: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
28    ; GFX9: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr0
29    ; GFX9: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 [[COPY]], [[COPY1]], implicit-def $scc
30    ; GFX9: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 [[COPY2]], [[S_ADD_I32_]], 0, implicit $exec
31    ; GFX9: [[V_ADD_U32_e64_1:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 [[S_ADD_I32_]], [[V_ADD_U32_e64_]], 0, implicit $exec
32    ; GFX9: [[V_ADD_U32_e64_2:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 [[V_ADD_U32_e64_1]], [[COPY2]], 0, implicit $exec
33    ; GFX9: S_ENDPGM 0, implicit [[S_ADD_I32_]], implicit [[V_ADD_U32_e64_]], implicit [[V_ADD_U32_e64_1]], implicit [[V_ADD_U32_e64_2]]
34    %0:sgpr(s32) = COPY $sgpr0
35    %1:sgpr(s32) = COPY $sgpr1
36    %2:vgpr(s32) = COPY $vgpr0
37    %3:vgpr(p1) = COPY $vgpr3_vgpr4
38    %4:sgpr(s32) = G_CONSTANT i32 1
39    %5:sgpr(s32) = G_CONSTANT i32 4096
40
41    ; add ss
42    %6:sgpr(s32) = G_ADD %0, %1
43
44    ; add vs
45    %7:vgpr(s32) = G_ADD %2, %6
46
47    ; add sv
48    %8:vgpr(s32) = G_ADD %6, %7
49
50    ; add vv
51    %9:vgpr(s32) = G_ADD %8, %2
52
53    S_ENDPGM 0, implicit %6, implicit %7, implicit %8, implicit %9
54
55...
56
57---
58name:            add_neg_inline_const_64_to_sub_s32_s
59legalized:       true
60regBankSelected: true
61tracksRegLiveness: true
62
63body: |
64  bb.0:
65    liveins: $sgpr0
66
67    ; GFX6-LABEL: name: add_neg_inline_const_64_to_sub_s32_s
68    ; GFX6: liveins: $sgpr0
69    ; GFX6: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
70    ; GFX6: [[S_SUB_I32_:%[0-9]+]]:sreg_32 = S_SUB_I32 [[COPY]], 64, implicit-def $scc
71    ; GFX6: S_ENDPGM 0, implicit [[S_SUB_I32_]]
72    ; GFX9-LABEL: name: add_neg_inline_const_64_to_sub_s32_s
73    ; GFX9: liveins: $sgpr0
74    ; GFX9: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
75    ; GFX9: [[S_SUB_I32_:%[0-9]+]]:sreg_32 = S_SUB_I32 [[COPY]], 64, implicit-def $scc
76    ; GFX9: S_ENDPGM 0, implicit [[S_SUB_I32_]]
77    %0:sgpr(s32) = COPY $sgpr0
78    %1:sgpr(s32) = G_CONSTANT i32 -64
79    %2:sgpr(s32) = G_ADD %0, %1
80    S_ENDPGM 0, implicit %2
81
82...
83
84---
85name:            add_neg_inline_const_64_to_sub_s32_v
86legalized:       true
87regBankSelected: true
88tracksRegLiveness: true
89
90body: |
91  bb.0:
92    liveins: $vgpr0
93
94    ; GFX6-LABEL: name: add_neg_inline_const_64_to_sub_s32_v
95    ; GFX6: liveins: $vgpr0
96    ; GFX6: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
97    ; GFX6: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 4294967232, implicit $exec
98    ; GFX6: %2:vgpr_32, dead %3:sreg_64_xexec = V_ADD_I32_e64 [[COPY]], [[V_MOV_B32_e32_]], 0, implicit $exec
99    ; GFX6: S_ENDPGM 0, implicit %2
100    ; GFX9-LABEL: name: add_neg_inline_const_64_to_sub_s32_v
101    ; GFX9: liveins: $vgpr0
102    ; GFX9: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
103    ; GFX9: [[V_SUB_U32_e64_:%[0-9]+]]:vgpr_32 = V_SUB_U32_e64 [[COPY]], 64, 0, implicit $exec
104    ; GFX9: S_ENDPGM 0, implicit [[V_SUB_U32_e64_]]
105    %0:vgpr(s32) = COPY $vgpr0
106    %1:vgpr(s32) = G_CONSTANT i32 -64
107    %2:vgpr(s32) = G_ADD %0, %1
108    S_ENDPGM 0, implicit %2
109
110...
111
112---
113name:            add_neg_inline_const_16_to_sub_s32_s
114legalized:       true
115regBankSelected: true
116tracksRegLiveness: true
117
118body: |
119  bb.0:
120    liveins: $sgpr0
121
122    ; GFX6-LABEL: name: add_neg_inline_const_16_to_sub_s32_s
123    ; GFX6: liveins: $sgpr0
124    ; GFX6: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
125    ; GFX6: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 16
126    ; GFX6: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 [[COPY]], [[S_MOV_B32_]], implicit-def $scc
127    ; GFX6: S_ENDPGM 0, implicit [[S_ADD_I32_]]
128    ; GFX9-LABEL: name: add_neg_inline_const_16_to_sub_s32_s
129    ; GFX9: liveins: $sgpr0
130    ; GFX9: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
131    ; GFX9: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 16
132    ; GFX9: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 [[COPY]], [[S_MOV_B32_]], implicit-def $scc
133    ; GFX9: S_ENDPGM 0, implicit [[S_ADD_I32_]]
134    %0:sgpr(s32) = COPY $sgpr0
135    %1:sgpr(s32) = G_CONSTANT i32 16
136    %2:sgpr(s32) = G_ADD %0, %1
137    S_ENDPGM 0, implicit %2
138
139...
140
141---
142name:            add_neg_inline_const_16_to_sub_s32_v
143legalized:       true
144regBankSelected: true
145tracksRegLiveness: true
146
147body: |
148  bb.0:
149    liveins: $vgpr0
150
151    ; GFX6-LABEL: name: add_neg_inline_const_16_to_sub_s32_v
152    ; GFX6: liveins: $vgpr0
153    ; GFX6: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
154    ; GFX6: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 16, implicit $exec
155    ; GFX6: %2:vgpr_32, dead %3:sreg_64_xexec = V_ADD_I32_e64 [[COPY]], [[V_MOV_B32_e32_]], 0, implicit $exec
156    ; GFX6: S_ENDPGM 0, implicit %2
157    ; GFX9-LABEL: name: add_neg_inline_const_16_to_sub_s32_v
158    ; GFX9: liveins: $vgpr0
159    ; GFX9: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
160    ; GFX9: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 16, implicit $exec
161    ; GFX9: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 [[COPY]], [[V_MOV_B32_e32_]], 0, implicit $exec
162    ; GFX9: S_ENDPGM 0, implicit [[V_ADD_U32_e64_]]
163    %0:vgpr(s32) = COPY $vgpr0
164    %1:vgpr(s32) = G_CONSTANT i32 16
165    %2:vgpr(s32) = G_ADD %0, %1
166    S_ENDPGM 0, implicit %2
167
168...
169