1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=amdgcn-amd-mesa3d -mcpu=fiji -verify-machineinstrs | FileCheck -check-prefix=VI %s
3 ; RUN: llc < %s -mtriple=amdgcn-amd-mesa3d -mcpu=gfx900 -verify-machineinstrs | FileCheck -check-prefix=GFX9 %s
4 ; RUN: llc < %s -mtriple=amdgcn-amd-mesa3d -mcpu=gfx1010 -verify-machineinstrs | FileCheck -check-prefix=GFX10 %s
6 ; ===================================================================================
8 ; ===================================================================================
10 define amdgpu_ps float @add_shl(i32 %a, i32 %b, i32 %c) {
13 ; VI-NEXT: v_add_u32_e32 v0, vcc, v0, v1
14 ; VI-NEXT: v_lshlrev_b32_e32 v0, v2, v0
15 ; VI-NEXT: ; return to shader part epilog
17 ; GFX9-LABEL: add_shl:
19 ; GFX9-NEXT: v_add_lshl_u32 v0, v0, v1, v2
20 ; GFX9-NEXT: ; return to shader part epilog
22 ; GFX10-LABEL: add_shl:
24 ; GFX10-NEXT: v_add_lshl_u32 v0, v0, v1, v2
25 ; GFX10-NEXT: ; implicit-def: $vcc_hi
26 ; GFX10-NEXT: ; return to shader part epilog
28 %result = shl i32 %x, %c
29 %bc = bitcast i32 %result to float
33 define amdgpu_ps float @add_shl_vgpr_c(i32 inreg %a, i32 inreg %b, i32 %c) {
34 ; VI-LABEL: add_shl_vgpr_c:
36 ; VI-NEXT: s_add_i32 s2, s2, s3
37 ; VI-NEXT: v_lshlrev_b32_e64 v0, v0, s2
38 ; VI-NEXT: ; return to shader part epilog
40 ; GFX9-LABEL: add_shl_vgpr_c:
42 ; GFX9-NEXT: s_add_i32 s2, s2, s3
43 ; GFX9-NEXT: v_lshlrev_b32_e64 v0, v0, s2
44 ; GFX9-NEXT: ; return to shader part epilog
46 ; GFX10-LABEL: add_shl_vgpr_c:
48 ; GFX10-NEXT: v_add_lshl_u32 v0, s2, s3, v0
49 ; GFX10-NEXT: ; implicit-def: $vcc_hi
50 ; GFX10-NEXT: ; return to shader part epilog
52 %result = shl i32 %x, %c
53 %bc = bitcast i32 %result to float
57 define amdgpu_ps float @add_shl_vgpr_ac(i32 %a, i32 inreg %b, i32 %c) {
58 ; VI-LABEL: add_shl_vgpr_ac:
60 ; VI-NEXT: v_add_u32_e32 v0, vcc, s2, v0
61 ; VI-NEXT: v_lshlrev_b32_e32 v0, v1, v0
62 ; VI-NEXT: ; return to shader part epilog
64 ; GFX9-LABEL: add_shl_vgpr_ac:
66 ; GFX9-NEXT: v_add_lshl_u32 v0, v0, s2, v1
67 ; GFX9-NEXT: ; return to shader part epilog
69 ; GFX10-LABEL: add_shl_vgpr_ac:
71 ; GFX10-NEXT: v_add_lshl_u32 v0, v0, s2, v1
72 ; GFX10-NEXT: ; implicit-def: $vcc_hi
73 ; GFX10-NEXT: ; return to shader part epilog
75 %result = shl i32 %x, %c
76 %bc = bitcast i32 %result to float
80 define amdgpu_ps float @add_shl_vgpr_const(i32 %a, i32 %b) {
81 ; VI-LABEL: add_shl_vgpr_const:
83 ; VI-NEXT: v_add_u32_e32 v0, vcc, v0, v1
84 ; VI-NEXT: v_lshlrev_b32_e32 v0, 9, v0
85 ; VI-NEXT: ; return to shader part epilog
87 ; GFX9-LABEL: add_shl_vgpr_const:
89 ; GFX9-NEXT: v_add_lshl_u32 v0, v0, v1, 9
90 ; GFX9-NEXT: ; return to shader part epilog
92 ; GFX10-LABEL: add_shl_vgpr_const:
94 ; GFX10-NEXT: v_add_lshl_u32 v0, v0, v1, 9
95 ; GFX10-NEXT: ; implicit-def: $vcc_hi
96 ; GFX10-NEXT: ; return to shader part epilog
98 %result = shl i32 %x, 9
99 %bc = bitcast i32 %result to float
103 define amdgpu_ps float @add_shl_vgpr_const_inline_const(i32 %a) {
104 ; VI-LABEL: add_shl_vgpr_const_inline_const:
106 ; VI-NEXT: v_lshlrev_b32_e32 v0, 9, v0
107 ; VI-NEXT: v_add_u32_e32 v0, vcc, 0x7e800, v0
108 ; VI-NEXT: ; return to shader part epilog
110 ; GFX9-LABEL: add_shl_vgpr_const_inline_const:
112 ; GFX9-NEXT: v_mov_b32_e32 v1, 0x7e800
113 ; GFX9-NEXT: v_lshl_add_u32 v0, v0, 9, v1
114 ; GFX9-NEXT: ; return to shader part epilog
116 ; GFX10-LABEL: add_shl_vgpr_const_inline_const:
118 ; GFX10-NEXT: v_lshl_add_u32 v0, v0, 9, 0x7e800
119 ; GFX10-NEXT: ; implicit-def: $vcc_hi
120 ; GFX10-NEXT: ; return to shader part epilog
121 %x = add i32 %a, 1012
122 %result = shl i32 %x, 9
123 %bc = bitcast i32 %result to float
127 ; TODO: Non-optimal code generation because SelectionDAG combines
128 ; (shl (add x, CONST), y) ---> (add (shl x, y), CONST').
130 define amdgpu_ps float @add_shl_vgpr_inline_const_x2(i32 %a) {
131 ; VI-LABEL: add_shl_vgpr_inline_const_x2:
133 ; VI-NEXT: v_lshlrev_b32_e32 v0, 9, v0
134 ; VI-NEXT: v_add_u32_e32 v0, vcc, 0x600, v0
135 ; VI-NEXT: ; return to shader part epilog
137 ; GFX9-LABEL: add_shl_vgpr_inline_const_x2:
139 ; GFX9-NEXT: v_mov_b32_e32 v1, 0x600
140 ; GFX9-NEXT: v_lshl_add_u32 v0, v0, 9, v1
141 ; GFX9-NEXT: ; return to shader part epilog
143 ; GFX10-LABEL: add_shl_vgpr_inline_const_x2:
145 ; GFX10-NEXT: v_lshl_add_u32 v0, v0, 9, 0x600
146 ; GFX10-NEXT: ; implicit-def: $vcc_hi
147 ; GFX10-NEXT: ; return to shader part epilog
149 %result = shl i32 %x, 9
150 %bc = bitcast i32 %result to float