1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -march=amdgcn -mcpu=fiji -run-pass=instruction-select -verify-machineinstrs -o - %s | FileCheck -check-prefix=GFX6 %s
3 # RUN: llc -march=amdgcn -mcpu=gfx900 -run-pass=instruction-select -verify-machineinstrs -o - %s | FileCheck -check-prefix=GFX6 %s
4 # RUN: llc -march=amdgcn -mcpu=gfx1010 -run-pass=instruction-select -verify-machineinstrs -o - %s | FileCheck -check-prefix=GFX10 %s
5 # RUN: llc -march=amdgcn -mcpu=gfx1100 -run-pass=instruction-select -verify-machineinstrs -o - %s | FileCheck -check-prefix=GFX10 %s
7 # Note: 16-bit instructions generally produce a 0 result in the high 16-bits on GFX8 and GFX9 and preserve high 16 bits on GFX10+
13 tracksRegLiveness: true
17 liveins: $vgpr0, $vgpr1
19 ; GFX6-LABEL: name: add_s16
20 ; GFX6: liveins: $vgpr0, $vgpr1
22 ; GFX6-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
23 ; GFX6-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
24 ; GFX6-NEXT: [[V_ADD_U16_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U16_e64 [[COPY]], [[COPY1]], 0, implicit $exec
25 ; GFX6-NEXT: S_ENDPGM 0, implicit [[V_ADD_U16_e64_]]
26 ; GFX10-LABEL: name: add_s16
27 ; GFX10: liveins: $vgpr0, $vgpr1
29 ; GFX10-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
30 ; GFX10-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
31 ; GFX10-NEXT: [[V_ADD_NC_U16_e64_:%[0-9]+]]:vgpr_32 = V_ADD_NC_U16_e64 0, [[COPY]], 0, [[COPY1]], 0, 0, implicit $exec
32 ; GFX10-NEXT: S_ENDPGM 0, implicit [[V_ADD_NC_U16_e64_]]
33 %0:vgpr(s32) = COPY $vgpr0
34 %1:vgpr(s32) = COPY $vgpr1
35 %2:vgpr(s16) = G_TRUNC %0
36 %3:vgpr(s16) = G_TRUNC %1
37 %4:vgpr(s16) = G_ADD %2, %3
38 S_ENDPGM 0, implicit %4
43 name: add_s16_zext_to_s32
46 tracksRegLiveness: true
50 liveins: $vgpr0, $vgpr1
52 ; GFX6-LABEL: name: add_s16_zext_to_s32
53 ; GFX6: liveins: $vgpr0, $vgpr1
55 ; GFX6-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
56 ; GFX6-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
57 ; GFX6-NEXT: [[V_ADD_U16_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U16_e64 [[COPY]], [[COPY1]], 0, implicit $exec
58 ; GFX6-NEXT: S_ENDPGM 0, implicit [[V_ADD_U16_e64_]]
59 ; GFX10-LABEL: name: add_s16_zext_to_s32
60 ; GFX10: liveins: $vgpr0, $vgpr1
62 ; GFX10-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
63 ; GFX10-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
64 ; GFX10-NEXT: [[V_ADD_NC_U16_e64_:%[0-9]+]]:vgpr_32 = V_ADD_NC_U16_e64 0, [[COPY]], 0, [[COPY1]], 0, 0, implicit $exec
65 ; GFX10-NEXT: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 65535
66 ; GFX10-NEXT: [[V_AND_B32_e64_:%[0-9]+]]:vgpr_32 = V_AND_B32_e64 [[S_MOV_B32_]], [[V_ADD_NC_U16_e64_]], implicit $exec
67 ; GFX10-NEXT: S_ENDPGM 0, implicit [[V_AND_B32_e64_]]
68 %0:vgpr(s32) = COPY $vgpr0
69 %1:vgpr(s32) = COPY $vgpr1
70 %2:vgpr(s16) = G_TRUNC %0
71 %3:vgpr(s16) = G_TRUNC %1
72 %4:vgpr(s16) = G_ADD %2, %3
73 %5:vgpr(s32) = G_ZEXT %4
74 S_ENDPGM 0, implicit %5
79 name: add_s16_neg_inline_const_64
82 tracksRegLiveness: true
88 ; GFX6-LABEL: name: add_s16_neg_inline_const_64
89 ; GFX6: liveins: $vgpr0
91 ; GFX6-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
92 ; GFX6-NEXT: [[V_SUB_U16_e64_:%[0-9]+]]:vgpr_32 = V_SUB_U16_e64 [[COPY]], 64, 0, implicit $exec
93 ; GFX6-NEXT: S_ENDPGM 0, implicit [[V_SUB_U16_e64_]]
94 ; GFX10-LABEL: name: add_s16_neg_inline_const_64
95 ; GFX10: liveins: $vgpr0
97 ; GFX10-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
98 ; GFX10-NEXT: [[V_SUB_NC_U16_e64_:%[0-9]+]]:vgpr_32 = V_SUB_NC_U16_e64 0, [[COPY]], 0, 64, 0, 0, implicit $exec
99 ; GFX10-NEXT: S_ENDPGM 0, implicit [[V_SUB_NC_U16_e64_]]
100 %0:vgpr(s32) = COPY $vgpr0
101 %1:vgpr(s16) = G_TRUNC %0
102 %2:vgpr(s16) = G_CONSTANT i16 -64
103 %3:vgpr(s16) = G_ADD %1, %2
104 S_ENDPGM 0, implicit %3
109 name: add_s16_neg_inline_const_64_zext_to_s32
111 regBankSelected: true
112 tracksRegLiveness: true
118 ; GFX6-LABEL: name: add_s16_neg_inline_const_64_zext_to_s32
119 ; GFX6: liveins: $vgpr0
121 ; GFX6-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
122 ; GFX6-NEXT: [[V_SUB_U16_e64_:%[0-9]+]]:vgpr_32 = V_SUB_U16_e64 [[COPY]], 64, 0, implicit $exec
123 ; GFX6-NEXT: S_ENDPGM 0, implicit [[V_SUB_U16_e64_]]
124 ; GFX10-LABEL: name: add_s16_neg_inline_const_64_zext_to_s32
125 ; GFX10: liveins: $vgpr0
127 ; GFX10-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
128 ; GFX10-NEXT: [[V_SUB_NC_U16_e64_:%[0-9]+]]:vgpr_32 = V_SUB_NC_U16_e64 0, [[COPY]], 0, 64, 0, 0, implicit $exec
129 ; GFX10-NEXT: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 65535
130 ; GFX10-NEXT: [[V_AND_B32_e64_:%[0-9]+]]:vgpr_32 = V_AND_B32_e64 [[S_MOV_B32_]], [[V_SUB_NC_U16_e64_]], implicit $exec
131 ; GFX10-NEXT: S_ENDPGM 0, implicit [[V_AND_B32_e64_]]
132 %0:vgpr(s32) = COPY $vgpr0
133 %1:vgpr(s16) = G_TRUNC %0
134 %2:vgpr(s16) = G_CONSTANT i16 -64
135 %3:vgpr(s16) = G_ADD %1, %2
136 %4:vgpr(s32) = G_ZEXT %3
137 S_ENDPGM 0, implicit %4