| 1 |
// |jit-test| skip-if: !wasmSimdEnabled() || !hasDisassembler() || wasmCompileMode() != "ion" || !getBuildConfiguration("x64") || getBuildConfiguration("simulator") || !isAvxPresent(); include:codegen-x64-test.js |
| 2 |
|
| 3 |
// Test that there are no extraneous moves for various SIMD conversion |
| 4 |
// operations. See README-codegen.md for general information about this type of |
| 5 |
// test case. |
| 6 |
|
| 7 |
// Note, these tests test the beginning of the output but not the end. |
| 8 |
|
| 9 |
// Currently AVX2 exhibits a defect when function uses its first v128 arg and |
| 10 |
// returns v128: the register allocator adds unneeded extra moves from xmm0, |
| 11 |
// then into different temporary, and then the latter temporary is used as arg. |
| 12 |
// In the tests below, to simplify things, don't use/ignore the first arg. |
| 13 |
// v128 OP v128 -> v128 |
| 14 |
// inputs: [[complete-opname, expected-pattern], ...] |
| 15 |
function codegenTestX64_v128xv128_v128_avxhack(inputs, options = {}) { |
| 16 |
for ( let [op, expected] of inputs ) { |
| 17 |
codegenTestX64_adhoc(wrap(options, ` |
| 18 |
(func (export "f") (param v128 v128 v128) (result v128) |
| 19 |
(${op} (local.get 1) (local.get 2)))`), |
| 20 |
'f', |
| 21 |
expected, |
| 22 |
options); |
| 23 |
} |
| 24 |
} |
| 25 |
// (see codegenTestX64_v128xv128_v128_avxhack comment about AVX defect) |
| 26 |
// v128 OP const -> v128 |
| 27 |
// inputs: [[complete-opname, const, expected-pattern], ...] |
| 28 |
function codegenTestX64_v128xLITERAL_v128_avxhack(inputs, options = {}) { |
| 29 |
for ( let [op, const_, expected] of inputs ) { |
| 30 |
codegenTestX64_adhoc(wrap(options, ` |
| 31 |
(func (export "f") (param v128 v128) (result v128) |
| 32 |
(${op} (local.get 1) ${const_}))`), |
| 33 |
'f', |
| 34 |
expected, |
| 35 |
options); |
| 36 |
} |
| 37 |
} |
| 38 |
// (see codegenTestX64_v128xv128_v128_avxhack comment about AVX defect) |
| 39 |
// const OP v128 -> v128 |
| 40 |
// inputs: [[complete-opname, const, expected-pattern], ...] |
| 41 |
function codegenTestX64_LITERALxv128_v128_avxhack(inputs, options = {}) { |
| 42 |
for ( let [op, const_, expected] of inputs ) { |
| 43 |
codegenTestX64_adhoc(wrap(options, ` |
| 44 |
(func (export "f") (param v128 v128) (result v128) |
| 45 |
(${op} ${const_} (local.get 1)))`), |
| 46 |
'f', |
| 47 |
expected, |
| 48 |
options); |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
// Utility function to test SIMD operations encoding, where the input argument |
| 53 |
// has the specified type (T). |
| 54 |
// inputs: [[type, complete-opname, expected-pattern], ...] |
| 55 |
function codegenTestX64_T_v128_avxhack(inputs, options = {}) { |
| 56 |
for ( let [ty, op, expected] of inputs ) { |
| 57 |
codegenTestX64_adhoc(wrap(options, ` |
| 58 |
(func (export "f") (param ${ty}) (result v128) |
| 59 |
(${op} (local.get 0)))`), |
| 60 |
'f', |
| 61 |
expected, |
| 62 |
options); |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
// Machers for any 64- and 32-bit registers. |
| 67 |
var GPR_I64 = "%r\\w+"; |
| 68 |
var GPR_I32 = "%(?:e\\w+|r\\d+d)"; |
| 69 |
|
| 70 |
// Simple binary ops: e.g. add, sub, mul |
| 71 |
codegenTestX64_v128xv128_v128_avxhack( |
| 72 |
[['i8x16.avgr_u', `c5 f1 e0 c2 vpavgb %xmm2, %xmm1, %xmm0`], |
| 73 |
['i16x8.avgr_u', `c5 f1 e3 c2 vpavgw %xmm2, %xmm1, %xmm0`], |
| 74 |
['i8x16.add', `c5 f1 fc c2 vpaddb %xmm2, %xmm1, %xmm0`], |
| 75 |
['i8x16.add_sat_s', `c5 f1 ec c2 vpaddsb %xmm2, %xmm1, %xmm0`], |
| 76 |
['i8x16.add_sat_u', `c5 f1 dc c2 vpaddusb %xmm2, %xmm1, %xmm0`], |
| 77 |
['i8x16.sub', `c5 f1 f8 c2 vpsubb %xmm2, %xmm1, %xmm0`], |
| 78 |
['i8x16.sub_sat_s', `c5 f1 e8 c2 vpsubsb %xmm2, %xmm1, %xmm0`], |
| 79 |
['i8x16.sub_sat_u', `c5 f1 d8 c2 vpsubusb %xmm2, %xmm1, %xmm0`], |
| 80 |
['i16x8.mul', `c5 f1 d5 c2 vpmullw %xmm2, %xmm1, %xmm0`], |
| 81 |
['i16x8.min_s', `c5 f1 ea c2 vpminsw %xmm2, %xmm1, %xmm0`], |
| 82 |
['i16x8.min_u', `c4 e2 71 3a c2 vpminuw %xmm2, %xmm1, %xmm0`], |
| 83 |
['i16x8.max_s', `c5 f1 ee c2 vpmaxsw %xmm2, %xmm1, %xmm0`], |
| 84 |
['i16x8.max_u', `c4 e2 71 3e c2 vpmaxuw %xmm2, %xmm1, %xmm0`], |
| 85 |
['i32x4.add', `c5 f1 fe c2 vpaddd %xmm2, %xmm1, %xmm0`], |
| 86 |
['i32x4.sub', `c5 f1 fa c2 vpsubd %xmm2, %xmm1, %xmm0`], |
| 87 |
['i32x4.mul', `c4 e2 71 40 c2 vpmulld %xmm2, %xmm1, %xmm0`], |
| 88 |
['i32x4.min_s', `c4 e2 71 39 c2 vpminsd %xmm2, %xmm1, %xmm0`], |
| 89 |
['i32x4.min_u', `c4 e2 71 3b c2 vpminud %xmm2, %xmm1, %xmm0`], |
| 90 |
['i32x4.max_s', `c4 e2 71 3d c2 vpmaxsd %xmm2, %xmm1, %xmm0`], |
| 91 |
['i32x4.max_u', `c4 e2 71 3f c2 vpmaxud %xmm2, %xmm1, %xmm0`], |
| 92 |
['i64x2.add', `c5 f1 d4 c2 vpaddq %xmm2, %xmm1, %xmm0`], |
| 93 |
['i64x2.sub', `c5 f1 fb c2 vpsubq %xmm2, %xmm1, %xmm0`], |
| 94 |
['i64x2.mul', ` |
| 95 |
c5 e1 73 d1 20 vpsrlq \\$0x20, %xmm1, %xmm3 |
| 96 |
66 0f f4 da pmuludq %xmm2, %xmm3 |
| 97 |
c5 81 73 d2 20 vpsrlq \\$0x20, %xmm2, %xmm15 |
| 98 |
66 44 0f f4 f9 pmuludq %xmm1, %xmm15 |
| 99 |
66 44 0f d4 fb paddq %xmm3, %xmm15 |
| 100 |
66 41 0f 73 f7 20 psllq \\$0x20, %xmm15 |
| 101 |
c5 f1 f4 c2 vpmuludq %xmm2, %xmm1, %xmm0 |
| 102 |
66 41 0f d4 c7 paddq %xmm15, %xmm0`], |
| 103 |
['f32x4.add', `c5 f0 58 c2 vaddps %xmm2, %xmm1, %xmm0`], |
| 104 |
['f32x4.sub', `c5 f0 5c c2 vsubps %xmm2, %xmm1, %xmm0`], |
| 105 |
['f32x4.mul', `c5 f0 59 c2 vmulps %xmm2, %xmm1, %xmm0`], |
| 106 |
['f32x4.div', `c5 f0 5e c2 vdivps %xmm2, %xmm1, %xmm0`], |
| 107 |
['f64x2.add', `c5 f1 58 c2 vaddpd %xmm2, %xmm1, %xmm0`], |
| 108 |
['f64x2.sub', `c5 f1 5c c2 vsubpd %xmm2, %xmm1, %xmm0`], |
| 109 |
['f64x2.mul', `c5 f1 59 c2 vmulpd %xmm2, %xmm1, %xmm0`], |
| 110 |
['f64x2.div', `c5 f1 5e c2 vdivpd %xmm2, %xmm1, %xmm0`], |
| 111 |
['i8x16.narrow_i16x8_s', `c5 f1 63 c2 vpacksswb %xmm2, %xmm1, %xmm0`], |
| 112 |
['i8x16.narrow_i16x8_u', `c5 f1 67 c2 vpackuswb %xmm2, %xmm1, %xmm0`], |
| 113 |
['i16x8.narrow_i32x4_s', `c5 f1 6b c2 vpackssdw %xmm2, %xmm1, %xmm0`], |
| 114 |
['i16x8.narrow_i32x4_u', `c4 e2 71 2b c2 vpackusdw %xmm2, %xmm1, %xmm0`], |
| 115 |
['i32x4.dot_i16x8_s', `c5 f1 f5 c2 vpmaddwd %xmm2, %xmm1, %xmm0`]]); |
| 116 |
|
| 117 |
// Simple comparison ops |
| 118 |
codegenTestX64_v128xv128_v128_avxhack( |
| 119 |
[['i8x16.eq', `c5 f1 74 c2 vpcmpeqb %xmm2, %xmm1, %xmm0`], |
| 120 |
['i8x16.ne', ` |
| 121 |
c5 f1 74 c2 vpcmpeqb %xmm2, %xmm1, %xmm0 |
| 122 |
66 45 0f 75 ff pcmpeqw %xmm15, %xmm15 |
| 123 |
66 41 0f ef c7 pxor %xmm15, %xmm0`], |
| 124 |
['i8x16.lt_s', `c5 e9 64 c1 vpcmpgtb %xmm1, %xmm2, %xmm0`], |
| 125 |
['i8x16.gt_u', ` |
| 126 |
c5 f1 de c2 vpmaxub %xmm2, %xmm1, %xmm0 |
| 127 |
66 0f 74 c2 pcmpeqb %xmm2, %xmm0 |
| 128 |
66 45 0f 75 ff pcmpeqw %xmm15, %xmm15 |
| 129 |
66 41 0f ef c7 pxor %xmm15, %xmm0`], |
| 130 |
['i16x8.eq', `c5 f1 75 c2 vpcmpeqw %xmm2, %xmm1, %xmm0`], |
| 131 |
['i16x8.ne', ` |
| 132 |
c5 f1 75 c2 vpcmpeqw %xmm2, %xmm1, %xmm0 |
| 133 |
66 45 0f 75 ff pcmpeqw %xmm15, %xmm15 |
| 134 |
66 41 0f ef c7 pxor %xmm15, %xmm0`], |
| 135 |
['i16x8.le_s', ` |
| 136 |
c5 f1 65 c2 vpcmpgtw %xmm2, %xmm1, %xmm0 |
| 137 |
66 45 0f 75 ff pcmpeqw %xmm15, %xmm15 |
| 138 |
66 41 0f ef c7 pxor %xmm15, %xmm0`], |
| 139 |
['i16x8.ge_u', ` |
| 140 |
c4 e2 71 3a c2 vpminuw %xmm2, %xmm1, %xmm0 |
| 141 |
66 0f 75 c2 pcmpeqw %xmm2, %xmm0`], |
| 142 |
['i32x4.eq', `c5 f1 76 c2 vpcmpeqd %xmm2, %xmm1, %xmm0`], |
| 143 |
['i32x4.ne', ` |
| 144 |
c5 f1 76 c2 vpcmpeqd %xmm2, %xmm1, %xmm0 |
| 145 |
66 45 0f 75 ff pcmpeqw %xmm15, %xmm15 |
| 146 |
66 41 0f ef c7 pxor %xmm15, %xmm0`], |
| 147 |
['i32x4.lt_s', `c5 e9 66 c1 vpcmpgtd %xmm1, %xmm2, %xmm0`], |
| 148 |
['i32x4.gt_u', ` |
| 149 |
c4 e2 71 3f c2 vpmaxud %xmm2, %xmm1, %xmm0 |
| 150 |
66 0f 76 c2 pcmpeqd %xmm2, %xmm0 |
| 151 |
66 45 0f 75 ff pcmpeqw %xmm15, %xmm15 |
| 152 |
66 41 0f ef c7 pxor %xmm15, %xmm0`], |
| 153 |
['i64x2.eq', `c4 e2 71 29 c2 vpcmpeqq %xmm2, %xmm1, %xmm0`], |
| 154 |
['i64x2.ne', ` |
| 155 |
c4 e2 71 29 c2 vpcmpeqq %xmm2, %xmm1, %xmm0 |
| 156 |
66 45 0f 75 ff pcmpeqw %xmm15, %xmm15 |
| 157 |
66 41 0f ef c7 pxor %xmm15, %xmm0`], |
| 158 |
['i64x2.lt_s', `c4 e2 69 37 c1 vpcmpgtq %xmm1, %xmm2, %xmm0`], |
| 159 |
['i64x2.ge_s', ` |
| 160 |
c4 e2 69 37 c1 vpcmpgtq %xmm1, %xmm2, %xmm0 |
| 161 |
66 45 0f 75 ff pcmpeqw %xmm15, %xmm15 |
| 162 |
66 41 0f ef c7 pxor %xmm15, %xmm0`], |
| 163 |
['f32x4.eq', `c5 f0 c2 c2 00 vcmpps \\$0x00, %xmm2, %xmm1, %xmm0`], |
| 164 |
['f32x4.lt', `c5 f0 c2 c2 01 vcmpps \\$0x01, %xmm2, %xmm1, %xmm0`], |
| 165 |
['f32x4.ge', `c5 e8 c2 c1 02 vcmpps \\$0x02, %xmm1, %xmm2, %xmm0`], |
| 166 |
['f64x2.eq', `c5 f1 c2 c2 00 vcmppd \\$0x00, %xmm2, %xmm1, %xmm0`], |
| 167 |
['f64x2.lt', `c5 f1 c2 c2 01 vcmppd \\$0x01, %xmm2, %xmm1, %xmm0`], |
| 168 |
['f64x2.ge', `c5 e9 c2 c1 02 vcmppd \\$0x02, %xmm1, %xmm2, %xmm0`], |
| 169 |
['f32x4.pmin', `c5 e8 5d c1 vminps %xmm1, %xmm2, %xmm0`], |
| 170 |
['f32x4.pmax', `c5 e8 5f c1 vmaxps %xmm1, %xmm2, %xmm0`], |
| 171 |
['f64x2.pmin', `c5 e9 5d c1 vminpd %xmm1, %xmm2, %xmm0`], |
| 172 |
['f64x2.pmax', `c5 e9 5f c1 vmaxpd %xmm1, %xmm2, %xmm0`], |
| 173 |
['i8x16.swizzle', ` |
| 174 |
c5 69 dc 3d ${RIPRADDR} vpaddusbx ${RIPR}, %xmm2, %xmm15 |
| 175 |
c4 c2 71 00 c7 vpshufb %xmm15, %xmm1, %xmm0`], |
| 176 |
['i16x8.extmul_high_i8x16_s', ` |
| 177 |
66 44 0f 3a 0f fa 08 palignr \\$0x08, %xmm2, %xmm15 |
| 178 |
c4 42 79 20 ff vpmovsxbw %xmm15, %xmm15 |
| 179 |
66 0f 3a 0f c1 08 palignr \\$0x08, %xmm1, %xmm0 |
| 180 |
c4 e2 79 20 c0 vpmovsxbw %xmm0, %xmm0 |
| 181 |
66 41 0f d5 c7 pmullw %xmm15, %xmm0`], |
| 182 |
['i32x4.extmul_low_i16x8_u', ` |
| 183 |
c5 71 e4 fa vpmulhuw %xmm2, %xmm1, %xmm15 |
| 184 |
c5 f1 d5 c2 vpmullw %xmm2, %xmm1, %xmm0 |
| 185 |
66 41 0f 61 c7 punpcklwd %xmm15, %xmm0`], |
| 186 |
['i64x2.extmul_low_i32x4_s', ` |
| 187 |
c5 79 70 f9 10 vpshufd \\$0x10, %xmm1, %xmm15 |
| 188 |
c5 f9 70 c2 10 vpshufd \\$0x10, %xmm2, %xmm0 |
| 189 |
66 41 0f 38 28 c7 pmuldq %xmm15, %xmm0`], |
| 190 |
['i16x8.q15mulr_sat_s', ` |
| 191 |
c4 e2 71 0b c2 vpmulhrsw %xmm2, %xmm1, %xmm0 |
| 192 |
c5 79 75 3d ${RIPRADDR} vpcmpeqwx ${RIPR}, %xmm0, %xmm15 |
| 193 |
66 41 0f ef c7 pxor %xmm15, %xmm0`], |
| 194 |
]); |
| 195 |
|
| 196 |
// Bitwise binary ops |
| 197 |
codegenTestX64_v128xv128_v128_avxhack( |
| 198 |
[['v128.and', `c5 f1 db c2 vpand %xmm2, %xmm1, %xmm0`], |
| 199 |
['v128.andnot', `c5 e9 df c1 vpandn %xmm1, %xmm2, %xmm0`], |
| 200 |
['v128.or', `c5 f1 eb c2 vpor %xmm2, %xmm1, %xmm0`], |
| 201 |
['v128.xor', `c5 f1 ef c2 vpxor %xmm2, %xmm1, %xmm0`]]); |
| 202 |
|
| 203 |
|
| 204 |
// Replace lane ops. |
| 205 |
codegenTestX64_adhoc(`(module |
| 206 |
(func (export "f") (param v128 v128 i32) (result v128) |
| 207 |
(i8x16.replace_lane 7 (local.get 1) (local.get 2))))`, 'f', ` |
| 208 |
c4 .. 71 20 .. 07 vpinsrb \\$0x07, ${GPR_I32}, %xmm1, %xmm0`); |
| 209 |
codegenTestX64_adhoc(`(module |
| 210 |
(func (export "f") (param v128 v128 i32) (result v128) |
| 211 |
(i16x8.replace_lane 3 (local.get 1) (local.get 2))))`, 'f', ` |
| 212 |
(?:c4 .. 71|c5 f1) c4 .. 03 vpinsrw \\$0x03, ${GPR_I32}, %xmm1, %xmm0`); |
| 213 |
codegenTestX64_adhoc(`(module |
| 214 |
(func (export "f") (param v128 v128 i32) (result v128) |
| 215 |
(i32x4.replace_lane 2 (local.get 1) (local.get 2))))`, 'f', ` |
| 216 |
c4 .. 71 22 .. 02 vpinsrd \\$0x02, ${GPR_I32}, %xmm1, %xmm0`); |
| 217 |
codegenTestX64_adhoc(`(module |
| 218 |
(func (export "f") (param v128 v128 i64) (result v128) |
| 219 |
(i64x2.replace_lane 1 (local.get 1) (local.get 2))))`, 'f', ` |
| 220 |
c4 .. f1 22 .. 01 vpinsrq \\$0x01, ${GPR_I64}, %xmm1, %xmm0`); |
| 221 |
|
| 222 |
|
| 223 |
if (isAvxPresent(2)) { |
| 224 |
codegenTestX64_T_v128_avxhack( |
| 225 |
[['i32', 'i8x16.splat', ` |
| 226 |
c5 f9 6e .. vmovd ${GPR_I32}, %xmm0 |
| 227 |
c4 e2 79 78 c0 vpbroadcastb %xmm0, %xmm0`], |
| 228 |
['i32', 'i16x8.splat', ` |
| 229 |
c5 f9 6e .. vmovd ${GPR_I32}, %xmm0 |
| 230 |
c4 e2 79 79 c0 vpbroadcastw %xmm0, %xmm0`], |
| 231 |
['i32', 'i32x4.splat', ` |
| 232 |
c5 f9 6e .. vmovd ${GPR_I32}, %xmm0 |
| 233 |
c4 e2 79 58 c0 vpbroadcastd %xmm0, %xmm0`], |
| 234 |
['i64', 'i64x2.splat', ` |
| 235 |
c4 e1 f9 6e .. vmovq ${GPR_I64}, %xmm0 |
| 236 |
c4 e2 79 59 c0 vpbroadcastq %xmm0, %xmm0`], |
| 237 |
['f32', 'f32x4.splat', `c4 e2 79 18 c0 vbroadcastss %xmm0, %xmm0`]], {log:true}); |
| 238 |
|
| 239 |
codegenTestX64_T_v128_avxhack( |
| 240 |
[['i32', 'v128.load8_splat', |
| 241 |
'c4 c2 79 78 04 .. vpbroadcastbb \\(%r15,%r\\w+,1\\), %xmm0'], |
| 242 |
['i32', 'v128.load16_splat', |
| 243 |
'c4 c2 79 79 04 .. vpbroadcastww \\(%r15,%r\\w+,1\\), %xmm0'], |
| 244 |
['i32', 'v128.load32_splat', |
| 245 |
'c4 c2 79 18 04 .. vbroadcastssl \\(%r15,%r\\w+,1\\), %xmm0']], {memory: 1}); |
| 246 |
} |
| 247 |
|
| 248 |
// Using VEX during shuffle ops |
| 249 |
codegenTestX64_v128xv128_v128_avxhack([ |
| 250 |
// Identity op on second argument should generate a move |
| 251 |
['i8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15', |
| 252 |
'c5 f9 6f c1 vmovdqa %xmm1, %xmm0'], |
| 253 |
|
| 254 |
// Broadcast a byte from first argument |
| 255 |
['i8x16.shuffle 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5', |
| 256 |
` |
| 257 |
c5 f1 60 c1 vpunpcklbw %xmm1, %xmm1, %xmm0 |
| 258 |
c5 fa 70 c0 55 vpshufhw \\$0x55, %xmm0, %xmm0 |
| 259 |
c5 f9 70 c0 aa vpshufd \\$0xAA, %xmm0, %xmm0`], |
| 260 |
|
| 261 |
// Broadcast a word from first argument |
| 262 |
['i8x16.shuffle 4 5 4 5 4 5 4 5 4 5 4 5 4 5 4 5', |
| 263 |
` |
| 264 |
c5 fb 70 c1 aa vpshuflw \\$0xAA, %xmm1, %xmm0 |
| 265 |
c5 f9 70 c0 00 vpshufd \\$0x00, %xmm0, %xmm0`], |
| 266 |
|
| 267 |
// Permute words |
| 268 |
['i8x16.shuffle 2 3 0 1 6 7 4 5 10 11 8 9 14 15 12 13', |
| 269 |
` |
| 270 |
c5 fb 70 c1 b1 vpshuflw \\$0xB1, %xmm1, %xmm0 |
| 271 |
c5 fa 70 c0 b1 vpshufhw \\$0xB1, %xmm0, %xmm0`], |
| 272 |
|
| 273 |
// Permute doublewords |
| 274 |
['i8x16.shuffle 4 5 6 7 0 1 2 3 12 13 14 15 8 9 10 11', |
| 275 |
'c5 f9 70 c1 b1 vpshufd \\$0xB1, %xmm1, %xmm0'], |
| 276 |
|
| 277 |
// Interleave doublewords |
| 278 |
['i8x16.shuffle 0 1 2 3 16 17 18 19 4 5 6 7 20 21 22 23', |
| 279 |
'c5 f1 62 c2 vpunpckldq %xmm2, %xmm1, %xmm0'], |
| 280 |
|
| 281 |
// Interleave quadwords |
| 282 |
['i8x16.shuffle 24 25 26 27 28 29 30 31 8 9 10 11 12 13 14 15', |
| 283 |
'c5 e9 6d c1 vpunpckhqdq %xmm1, %xmm2, %xmm0'], |
| 284 |
|
| 285 |
// Rotate right |
| 286 |
['i8x16.shuffle 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12', |
| 287 |
`c4 e3 71 0f c1 0d vpalignr \\$0x0D, %xmm1, %xmm1, %xmm0`], |
| 288 |
['i8x16.shuffle 28 29 30 31 0 1 2 3 4 5 6 7 8 9 10 11', |
| 289 |
`c4 e3 71 0f c2 0c vpalignr \\$0x0C, %xmm2, %xmm1, %xmm0`]]); |
| 290 |
|
| 291 |
if (isAvxPresent(2)) { |
| 292 |
codegenTestX64_v128xv128_v128_avxhack([ |
| 293 |
// Broadcast low byte from second argument |
| 294 |
['i8x16.shuffle 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0', |
| 295 |
'c4 e2 79 78 c1 vpbroadcastb %xmm1, %xmm0'], |
| 296 |
|
| 297 |
// Broadcast low word from third argument |
| 298 |
['i8x16.shuffle 16 17 16 17 16 17 16 17 16 17 16 17 16 17 16 17', |
| 299 |
'c4 e2 79 79 c2 vpbroadcastw %xmm2, %xmm0'], |
| 300 |
|
| 301 |
// Broadcast low doubleword from second argument |
| 302 |
['i8x16.shuffle 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3', |
| 303 |
'c4 e2 79 58 c1 vpbroadcastd %xmm1, %xmm0']]); |
| 304 |
} |
| 305 |
|
| 306 |
// Testing AVX optimization where VPBLENDVB accepts four XMM registers as args. |
| 307 |
codegenTestX64_adhoc( |
| 308 |
`(func (export "f") (param v128 v128 v128 v128) (result v128) |
| 309 |
(i8x16.shuffle 0 17 2 3 4 5 6 7 24 25 26 11 12 13 30 15 |
| 310 |
(local.get 2)(local.get 3)))`, |
| 311 |
'f', |
| 312 |
` |
| 313 |
66 0f 6f 0d ${RIPRADDR} movdqax ${RIPR}, %xmm1 |
| 314 |
c4 e3 69 4c c3 10 vpblendvb %xmm1, %xmm3, %xmm2, %xmm0`); |
| 315 |
|
| 316 |
// Constant arguments that are folded into the instruction |
| 317 |
codegenTestX64_v128xLITERAL_v128_avxhack( |
| 318 |
[['i8x16.add', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 319 |
`c5 f1 fc 05 ${RIPRADDR} vpaddbx ${RIPR}, %xmm1, %xmm0`], |
| 320 |
['i8x16.sub', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 321 |
`c5 f1 f8 05 ${RIPRADDR} vpsubbx ${RIPR}, %xmm1, %xmm0`], |
| 322 |
['i8x16.add_sat_s', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 323 |
`c5 f1 ec 05 ${RIPRADDR} vpaddsbx ${RIPR}, %xmm1, %xmm0`], |
| 324 |
['i8x16.add_sat_u', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 325 |
`c5 f1 dc 05 ${RIPRADDR} vpaddusbx ${RIPR}, %xmm1, %xmm0`], |
| 326 |
['i8x16.sub_sat_s', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 327 |
`c5 f1 e8 05 ${RIPRADDR} vpsubsbx ${RIPR}, %xmm1, %xmm0`], |
| 328 |
['i8x16.sub_sat_u', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 329 |
`c5 f1 d8 05 ${RIPRADDR} vpsubusbx ${RIPR}, %xmm1, %xmm0`], |
| 330 |
['i8x16.min_s', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 331 |
`c4 e2 71 38 05 ${RIPRADDR} vpminsbx ${RIPR}, %xmm1, %xmm0`], |
| 332 |
['i8x16.min_u', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 333 |
`c5 f1 da 05 ${RIPRADDR} vpminubx ${RIPR}, %xmm1, %xmm0`], |
| 334 |
['i8x16.max_s', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 335 |
`c4 e2 71 3c 05 ${RIPRADDR} vpmaxsbx ${RIPR}, %xmm1, %xmm0`], |
| 336 |
['i8x16.max_u', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 337 |
`c5 f1 de 05 ${RIPRADDR} vpmaxubx ${RIPR}, %xmm1, %xmm0`], |
| 338 |
['i8x16.eq', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 339 |
`c5 f1 74 05 ${RIPRADDR} vpcmpeqbx ${RIPR}, %xmm1, %xmm0`], |
| 340 |
['i8x16.ne', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', ` |
| 341 |
c5 f1 74 05 ${RIPRADDR} vpcmpeqbx ${RIPR}, %xmm1, %xmm0 |
| 342 |
66 45 0f 75 ff pcmpeqw %xmm15, %xmm15 |
| 343 |
66 41 0f ef c7 pxor %xmm15, %xmm0`], |
| 344 |
['i8x16.gt_s', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 345 |
`c5 f1 64 05 ${RIPRADDR} vpcmpgtbx ${RIPR}, %xmm1, %xmm0`], |
| 346 |
['i8x16.le_s', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', ` |
| 347 |
c5 f1 64 05 ${RIPRADDR} vpcmpgtbx ${RIPR}, %xmm1, %xmm0 |
| 348 |
66 45 0f 75 ff pcmpeqw %xmm15, %xmm15 |
| 349 |
66 41 0f ef c7 pxor %xmm15, %xmm0`], |
| 350 |
['i8x16.narrow_i16x8_s', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 351 |
`c5 f1 63 05 ${RIPRADDR} vpacksswbx ${RIPR}, %xmm1, %xmm0`], |
| 352 |
['i8x16.narrow_i16x8_u', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 353 |
`c5 f1 67 05 ${RIPRADDR} vpackuswbx ${RIPR}, %xmm1, %xmm0`], |
| 354 |
|
| 355 |
['i16x8.add', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 356 |
`c5 f1 fd 05 ${RIPRADDR} vpaddwx ${RIPR}, %xmm1, %xmm0`], |
| 357 |
['i16x8.sub', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 358 |
`c5 f1 f9 05 ${RIPRADDR} vpsubwx ${RIPR}, %xmm1, %xmm0`], |
| 359 |
['i16x8.mul', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 360 |
`c5 f1 d5 05 ${RIPRADDR} vpmullwx ${RIPR}, %xmm1, %xmm0`], |
| 361 |
['i16x8.add_sat_s', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 362 |
`c5 f1 ed 05 ${RIPRADDR} vpaddswx ${RIPR}, %xmm1, %xmm0`], |
| 363 |
['i16x8.add_sat_u', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 364 |
`c5 f1 dd 05 ${RIPRADDR} vpadduswx ${RIPR}, %xmm1, %xmm0`], |
| 365 |
['i16x8.sub_sat_s', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 366 |
`c5 f1 e9 05 ${RIPRADDR} vpsubswx ${RIPR}, %xmm1, %xmm0`], |
| 367 |
['i16x8.sub_sat_u', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 368 |
`c5 f1 d9 05 ${RIPRADDR} vpsubuswx ${RIPR}, %xmm1, %xmm0`], |
| 369 |
['i16x8.min_s', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 370 |
`c5 f1 ea 05 ${RIPRADDR} vpminswx ${RIPR}, %xmm1, %xmm0`], |
| 371 |
['i16x8.min_u', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 372 |
`c4 e2 71 3a 05 ${RIPRADDR} vpminuwx ${RIPR}, %xmm1, %xmm0`], |
| 373 |
['i16x8.max_s', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 374 |
`c5 f1 ee 05 ${RIPRADDR} vpmaxswx ${RIPR}, %xmm1, %xmm0`], |
| 375 |
['i16x8.max_u', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 376 |
`c4 e2 71 3e 05 ${RIPRADDR} vpmaxuwx ${RIPR}, %xmm1, %xmm0`], |
| 377 |
['i16x8.eq', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 378 |
`c5 f1 75 05 ${RIPRADDR} vpcmpeqwx ${RIPR}, %xmm1, %xmm0`], |
| 379 |
['i16x8.ne', '(v128.const i16x8 1 2 1 2 1 2 1 2)', ` |
| 380 |
c5 f1 75 05 ${RIPRADDR} vpcmpeqwx ${RIPR}, %xmm1, %xmm0 |
| 381 |
66 45 0f 75 ff pcmpeqw %xmm15, %xmm15 |
| 382 |
66 41 0f ef c7 pxor %xmm15, %xmm0`], |
| 383 |
['i16x8.gt_s', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 384 |
`c5 f1 65 05 ${RIPRADDR} vpcmpgtwx ${RIPR}, %xmm1, %xmm0`], |
| 385 |
['i16x8.le_s', '(v128.const i16x8 1 2 1 2 1 2 1 2)', ` |
| 386 |
c5 f1 65 05 ${RIPRADDR} vpcmpgtwx ${RIPR}, %xmm1, %xmm0 |
| 387 |
66 45 0f 75 ff pcmpeqw %xmm15, %xmm15 |
| 388 |
66 41 0f ef c7 pxor %xmm15, %xmm0`], |
| 389 |
['i16x8.narrow_i32x4_s', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 390 |
`c5 f1 6b 05 ${RIPRADDR} vpackssdwx ${RIPR}, %xmm1, %xmm0`], |
| 391 |
['i16x8.narrow_i32x4_u', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 392 |
`c4 e2 71 2b 05 ${RIPRADDR} vpackusdwx ${RIPR}, %xmm1, %xmm0`], |
| 393 |
|
| 394 |
['i32x4.add', '(v128.const i32x4 1 2 1 2)', |
| 395 |
`c5 f1 fe 05 ${RIPRADDR} vpadddx ${RIPR}, %xmm1, %xmm0`], |
| 396 |
['i32x4.sub', '(v128.const i32x4 1 2 1 2)', |
| 397 |
`c5 f1 fa 05 ${RIPRADDR} vpsubdx ${RIPR}, %xmm1, %xmm0`], |
| 398 |
['i32x4.mul', '(v128.const i32x4 1 2 1 2)', |
| 399 |
`c4 e2 71 40 05 ${RIPRADDR} vpmulldx ${RIPR}, %xmm1, %xmm0`], |
| 400 |
['i32x4.min_s', '(v128.const i32x4 1 2 1 2)', |
| 401 |
`c4 e2 71 39 05 ${RIPRADDR} vpminsdx ${RIPR}, %xmm1, %xmm0`], |
| 402 |
['i32x4.min_u', '(v128.const i32x4 1 2 1 2)', |
| 403 |
`c4 e2 71 3b 05 ${RIPRADDR} vpminudx ${RIPR}, %xmm1, %xmm0`], |
| 404 |
['i32x4.max_s', '(v128.const i32x4 1 2 1 2)', |
| 405 |
`c4 e2 71 3d 05 ${RIPRADDR} vpmaxsdx ${RIPR}, %xmm1, %xmm0`], |
| 406 |
['i32x4.max_u', '(v128.const i32x4 1 2 1 2)', |
| 407 |
`c4 e2 71 3f 05 ${RIPRADDR} vpmaxudx ${RIPR}, %xmm1, %xmm0`], |
| 408 |
['i32x4.eq', '(v128.const i32x4 1 2 1 2)', |
| 409 |
`c5 f1 76 05 ${RIPRADDR} vpcmpeqdx ${RIPR}, %xmm1, %xmm0`], |
| 410 |
['i32x4.ne', '(v128.const i32x4 1 2 1 2)', ` |
| 411 |
c5 f1 76 05 ${RIPRADDR} vpcmpeqdx ${RIPR}, %xmm1, %xmm0 |
| 412 |
66 45 0f 75 ff pcmpeqw %xmm15, %xmm15 |
| 413 |
66 41 0f ef c7 pxor %xmm15, %xmm0`], |
| 414 |
['i32x4.gt_s', '(v128.const i32x4 1 2 1 2)', |
| 415 |
`c5 f1 66 05 ${RIPRADDR} vpcmpgtdx ${RIPR}, %xmm1, %xmm0`], |
| 416 |
['i32x4.le_s', '(v128.const i32x4 1 2 1 2)', ` |
| 417 |
c5 f1 66 05 ${RIPRADDR} vpcmpgtdx ${RIPR}, %xmm1, %xmm0 |
| 418 |
66 45 0f 75 ff pcmpeqw %xmm15, %xmm15 |
| 419 |
66 41 0f ef c7 pxor %xmm15, %xmm0`], |
| 420 |
['i32x4.dot_i16x8_s', '(v128.const i32x4 1 2 1 2)', |
| 421 |
`c5 f1 f5 05 ${RIPRADDR} vpmaddwdx ${RIPR}, %xmm1, %xmm0`], |
| 422 |
|
| 423 |
['i64x2.add', '(v128.const i64x2 1 2)', |
| 424 |
`c5 f1 d4 05 ${RIPRADDR} vpaddqx ${RIPR}, %xmm1, %xmm0`], |
| 425 |
['i64x2.sub', '(v128.const i64x2 1 2)', |
| 426 |
`c5 f1 fb 05 ${RIPRADDR} vpsubqx ${RIPR}, %xmm1, %xmm0`], |
| 427 |
|
| 428 |
['v128.and', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 429 |
`c5 f1 db 05 ${RIPRADDR} vpandx ${RIPR}, %xmm1, %xmm0`], |
| 430 |
['v128.or', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 431 |
`c5 f1 eb 05 ${RIPRADDR} vporx ${RIPR}, %xmm1, %xmm0`], |
| 432 |
['v128.xor', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 433 |
`c5 f1 ef 05 ${RIPRADDR} vpxorx ${RIPR}, %xmm1, %xmm0`], |
| 434 |
|
| 435 |
['f32x4.add', '(v128.const f32x4 1 2 3 4)', |
| 436 |
`c5 f0 58 05 ${RIPRADDR} vaddpsx ${RIPR}, %xmm1, %xmm0`], |
| 437 |
['f32x4.sub', '(v128.const f32x4 1 2 3 4)', |
| 438 |
`c5 f0 5c 05 ${RIPRADDR} vsubpsx ${RIPR}, %xmm1, %xmm0`], |
| 439 |
['f32x4.mul', '(v128.const f32x4 1 2 3 4)', |
| 440 |
`c5 f0 59 05 ${RIPRADDR} vmulpsx ${RIPR}, %xmm1, %xmm0`], |
| 441 |
['f32x4.div', '(v128.const f32x4 1 2 3 4)', |
| 442 |
`c5 f0 5e 05 ${RIPRADDR} vdivpsx ${RIPR}, %xmm1, %xmm0`], |
| 443 |
|
| 444 |
['f64x2.add', '(v128.const f64x2 1 2)', |
| 445 |
`c5 f1 58 05 ${RIPRADDR} vaddpdx ${RIPR}, %xmm1, %xmm0`], |
| 446 |
['f64x2.sub', '(v128.const f64x2 1 2)', |
| 447 |
`c5 f1 5c 05 ${RIPRADDR} vsubpdx ${RIPR}, %xmm1, %xmm0`], |
| 448 |
['f64x2.mul', '(v128.const f64x2 1 2)', |
| 449 |
`c5 f1 59 05 ${RIPRADDR} vmulpdx ${RIPR}, %xmm1, %xmm0`], |
| 450 |
['f64x2.div', '(v128.const f64x2 1 2)', |
| 451 |
`c5 f1 5e 05 ${RIPRADDR} vdivpdx ${RIPR}, %xmm1, %xmm0`], |
| 452 |
|
| 453 |
['f32x4.eq', '(v128.const f32x4 1 2 3 4)', |
| 454 |
`c5 f0 c2 05 ${RIPRADDR} 00 vcmppsx \\$0x00, ${RIPR}, %xmm1, %xmm0`], |
| 455 |
['f32x4.ne', '(v128.const f32x4 1 2 3 4)', |
| 456 |
`c5 f0 c2 05 ${RIPRADDR} 04 vcmppsx \\$0x04, ${RIPR}, %xmm1, %xmm0`], |
| 457 |
['f32x4.lt', '(v128.const f32x4 1 2 3 4)', |
| 458 |
`c5 f0 c2 05 ${RIPRADDR} 01 vcmppsx \\$0x01, ${RIPR}, %xmm1, %xmm0`], |
| 459 |
['f32x4.le', '(v128.const f32x4 1 2 3 4)', |
| 460 |
`c5 f0 c2 05 ${RIPRADDR} 02 vcmppsx \\$0x02, ${RIPR}, %xmm1, %xmm0`], |
| 461 |
|
| 462 |
['f64x2.eq', '(v128.const f64x2 1 2)', |
| 463 |
`c5 f1 c2 05 ${RIPRADDR} 00 vcmppdx \\$0x00, ${RIPR}, %xmm1, %xmm0`], |
| 464 |
['f64x2.ne', '(v128.const f64x2 1 2)', |
| 465 |
`c5 f1 c2 05 ${RIPRADDR} 04 vcmppdx \\$0x04, ${RIPR}, %xmm1, %xmm0`], |
| 466 |
['f64x2.lt', '(v128.const f64x2 1 2)', |
| 467 |
`c5 f1 c2 05 ${RIPRADDR} 01 vcmppdx \\$0x01, ${RIPR}, %xmm1, %xmm0`], |
| 468 |
['f64x2.le', '(v128.const f64x2 1 2)', |
| 469 |
`c5 f1 c2 05 ${RIPRADDR} 02 vcmppdx \\$0x02, ${RIPR}, %xmm1, %xmm0`]]); |
| 470 |
|
| 471 |
// Commutative operations with constants on the lhs should generate the same |
| 472 |
// code as with the constant on the rhs. |
| 473 |
codegenTestX64_LITERALxv128_v128_avxhack( |
| 474 |
[['i8x16.add', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 475 |
`c5 f1 fc 05 ${RIPRADDR} vpaddbx ${RIPR}, %xmm1, %xmm0`], |
| 476 |
['i8x16.add_sat_s', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 477 |
`c5 f1 ec 05 ${RIPRADDR} vpaddsbx ${RIPR}, %xmm1, %xmm0`], |
| 478 |
['i8x16.add_sat_u', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 479 |
`c5 f1 dc 05 ${RIPRADDR} vpaddusbx ${RIPR}, %xmm1, %xmm0`], |
| 480 |
['i8x16.min_s', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 481 |
`c4 e2 71 38 05 ${RIPRADDR} vpminsbx ${RIPR}, %xmm1, %xmm0`], |
| 482 |
['i8x16.min_u', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 483 |
`c5 f1 da 05 ${RIPRADDR} vpminubx ${RIPR}, %xmm1, %xmm0`], |
| 484 |
['i8x16.max_s', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 485 |
`c4 e2 71 3c 05 ${RIPRADDR} vpmaxsbx ${RIPR}, %xmm1, %xmm0`], |
| 486 |
['i8x16.max_u', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 487 |
`c5 f1 de 05 ${RIPRADDR} vpmaxubx ${RIPR}, %xmm1, %xmm0`], |
| 488 |
['i8x16.eq', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 489 |
`c5 f1 74 05 ${RIPRADDR} vpcmpeqbx ${RIPR}, %xmm1, %xmm0`], |
| 490 |
['i8x16.ne', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', ` |
| 491 |
c5 f1 74 05 ${RIPRADDR} vpcmpeqbx ${RIPR}, %xmm1, %xmm0 |
| 492 |
66 45 0f 75 ff pcmpeqw %xmm15, %xmm15 |
| 493 |
66 41 0f ef c7 pxor %xmm15, %xmm0`], |
| 494 |
|
| 495 |
['i16x8.add', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 496 |
`c5 f1 fd 05 ${RIPRADDR} vpaddwx ${RIPR}, %xmm1, %xmm0`], |
| 497 |
['i16x8.mul', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 498 |
`c5 f1 d5 05 ${RIPRADDR} vpmullwx ${RIPR}, %xmm1, %xmm0`], |
| 499 |
['i16x8.add_sat_s', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 500 |
`c5 f1 ed 05 ${RIPRADDR} vpaddswx ${RIPR}, %xmm1, %xmm0`], |
| 501 |
['i16x8.add_sat_u', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 502 |
`c5 f1 dd 05 ${RIPRADDR} vpadduswx ${RIPR}, %xmm1, %xmm0`], |
| 503 |
['i16x8.min_s', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 504 |
`c5 f1 ea 05 ${RIPRADDR} vpminswx ${RIPR}, %xmm1, %xmm0`], |
| 505 |
['i16x8.min_u', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 506 |
`c4 e2 71 3a 05 ${RIPRADDR} vpminuwx ${RIPR}, %xmm1, %xmm0`], |
| 507 |
['i16x8.max_s', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 508 |
`c5 f1 ee 05 ${RIPRADDR} vpmaxswx ${RIPR}, %xmm1, %xmm0`], |
| 509 |
['i16x8.max_u', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 510 |
`c4 e2 71 3e 05 ${RIPRADDR} vpmaxuwx ${RIPR}, %xmm1, %xmm0`], |
| 511 |
['i16x8.eq', '(v128.const i16x8 1 2 1 2 1 2 1 2)', |
| 512 |
`c5 f1 75 05 ${RIPRADDR} vpcmpeqwx ${RIPR}, %xmm1, %xmm0`], |
| 513 |
['i16x8.ne', '(v128.const i16x8 1 2 1 2 1 2 1 2)', ` |
| 514 |
c5 f1 75 05 ${RIPRADDR} vpcmpeqwx ${RIPR}, %xmm1, %xmm0 |
| 515 |
66 45 0f 75 ff pcmpeqw %xmm15, %xmm15 |
| 516 |
66 41 0f ef c7 pxor %xmm15, %xmm0`], |
| 517 |
|
| 518 |
['i32x4.add', '(v128.const i32x4 1 2 1 2)', |
| 519 |
`c5 f1 fe 05 ${RIPRADDR} vpadddx ${RIPR}, %xmm1, %xmm0`], |
| 520 |
['i32x4.mul', '(v128.const i32x4 1 2 1 2)', |
| 521 |
`c4 e2 71 40 05 ${RIPRADDR} vpmulldx ${RIPR}, %xmm1, %xmm0`], |
| 522 |
['i32x4.min_s', '(v128.const i32x4 1 2 1 2)', |
| 523 |
`c4 e2 71 39 05 ${RIPRADDR} vpminsdx ${RIPR}, %xmm1, %xmm0`], |
| 524 |
['i32x4.min_u', '(v128.const i32x4 1 2 1 2)', |
| 525 |
`c4 e2 71 3b 05 ${RIPRADDR} vpminudx ${RIPR}, %xmm1, %xmm0`], |
| 526 |
['i32x4.max_s', '(v128.const i32x4 1 2 1 2)', |
| 527 |
`c4 e2 71 3d 05 ${RIPRADDR} vpmaxsdx ${RIPR}, %xmm1, %xmm0`], |
| 528 |
['i32x4.max_u', '(v128.const i32x4 1 2 1 2)', |
| 529 |
`c4 e2 71 3f 05 ${RIPRADDR} vpmaxudx ${RIPR}, %xmm1, %xmm0`], |
| 530 |
['i32x4.eq', '(v128.const i32x4 1 2 1 2)', |
| 531 |
`c5 f1 76 05 ${RIPRADDR} vpcmpeqdx ${RIPR}, %xmm1, %xmm0`], |
| 532 |
['i32x4.ne', '(v128.const i32x4 1 2 1 2)', ` |
| 533 |
c5 f1 76 05 ${RIPRADDR} vpcmpeqdx ${RIPR}, %xmm1, %xmm0 |
| 534 |
66 45 0f 75 ff pcmpeqw %xmm15, %xmm15 |
| 535 |
66 41 0f ef c7 pxor %xmm15, %xmm0`], |
| 536 |
['i32x4.dot_i16x8_s', '(v128.const i32x4 1 2 1 2)', |
| 537 |
`c5 f1 f5 05 ${RIPRADDR} vpmaddwdx ${RIPR}, %xmm1, %xmm0`], |
| 538 |
|
| 539 |
['i64x2.add', '(v128.const i64x2 1 2)', |
| 540 |
`c5 f1 d4 05 ${RIPRADDR} vpaddqx ${RIPR}, %xmm1, %xmm0`], |
| 541 |
|
| 542 |
['v128.and', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 543 |
`c5 f1 db 05 ${RIPRADDR} vpandx ${RIPR}, %xmm1, %xmm0`], |
| 544 |
['v128.or', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 545 |
`c5 f1 eb 05 ${RIPRADDR} vporx ${RIPR}, %xmm1, %xmm0`], |
| 546 |
['v128.xor', '(v128.const i8x16 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2)', |
| 547 |
`c5 f1 ef 05 ${RIPRADDR} vpxorx ${RIPR}, %xmm1, %xmm0`]]); |
| 548 |
|
| 549 |
// Shift by constant encodings |
| 550 |
codegenTestX64_v128xLITERAL_v128_avxhack( |
| 551 |
[['i8x16.shl', '(i32.const 2)', ` |
| 552 |
c5 f1 fc c1 vpaddb %xmm1, %xmm1, %xmm0 |
| 553 |
66 0f fc c0 paddb %xmm0, %xmm0`], |
| 554 |
['i8x16.shl', '(i32.const 4)', ` |
| 555 |
c5 f1 db 05 ${RIPRADDR} vpandx ${RIPR}, %xmm1, %xmm0 |
| 556 |
66 0f 71 f0 04 psllw \\$0x04, %xmm0`], |
| 557 |
['i16x8.shl', '(i32.const 1)', |
| 558 |
'c5 f9 71 f1 01 vpsllw \\$0x01, %xmm1, %xmm0'], |
| 559 |
['i16x8.shr_s', '(i32.const 3)', |
| 560 |
'c5 f9 71 e1 03 vpsraw \\$0x03, %xmm1, %xmm0'], |
| 561 |
['i16x8.shr_u', '(i32.const 2)', |
| 562 |
'c5 f9 71 d1 02 vpsrlw \\$0x02, %xmm1, %xmm0'], |
| 563 |
['i32x4.shl', '(i32.const 5)', |
| 564 |
'c5 f9 72 f1 05 vpslld \\$0x05, %xmm1, %xmm0'], |
| 565 |
['i32x4.shr_s', '(i32.const 2)', |
| 566 |
'c5 f9 72 e1 02 vpsrad \\$0x02, %xmm1, %xmm0'], |
| 567 |
['i32x4.shr_u', '(i32.const 5)', |
| 568 |
'c5 f9 72 d1 05 vpsrld \\$0x05, %xmm1, %xmm0'], |
| 569 |
['i64x2.shr_s', '(i32.const 7)', ` |
| 570 |
c5 79 70 f9 f5 vpshufd \\$0xF5, %xmm1, %xmm15 |
| 571 |
66 41 0f 72 e7 1f psrad \\$0x1F, %xmm15 |
| 572 |
c4 c1 71 ef c7 vpxor %xmm15, %xmm1, %xmm0 |
| 573 |
66 0f 73 d0 07 psrlq \\$0x07, %xmm0 |
| 574 |
66 41 0f ef c7 pxor %xmm15, %xmm0`]]); |
| 575 |
|
| 576 |
// vpblendvp optimization when bitselect follows comparison. |
| 577 |
codegenTestX64_adhoc( |
| 578 |
`(module |
| 579 |
(func (export "f") (param v128) (param v128) (param v128) (param v128) (result v128) |
| 580 |
(v128.bitselect (local.get 2) (local.get 3) |
| 581 |
(i32x4.eq (local.get 0) (local.get 1)))))`, |
| 582 |
'f', ` |
| 583 |
66 0f 76 c1 pcmpeqd %xmm1, %xmm0 |
| 584 |
c4 e3 61 4c c2 00 vpblendvb %xmm0, %xmm2, %xmm3, %xmm0`); |