Source file src/simd/archsimd/converts_gen_amd64.go
1 // Code generated by 'tmplgen'; DO NOT EDIT. 2 3 //go:build goexperiment.simd 4 5 package archsimd 6 7 // TruncToInt8 converts each element of x to int8 by discarding its high 8 // bits. 9 // 10 // z[i] = int8(x[i]) 11 // 12 // The results are stored in the low 8 elements of z. 13 // The remaining elements of z are zero. 14 // 15 // Emulated, CPU Feature: AVX 16 func (x Int16x8) TruncToInt8() (z Int8x16) { 17 return x.ToBits().TruncToUint8().BitsToInt8() 18 } 19 20 // TruncToUint8 converts each element of x to uint8 by discarding its high 21 // bits. 22 // 23 // z[i] = uint8(x[i]) 24 // 25 // The results are stored in the low 8 elements of z. 26 // The remaining elements of z are zero. 27 // 28 // Emulated, CPU Feature: AVX 29 func (x Uint16x8) TruncToUint8() (z Uint8x16) { 30 return x.ReshapeToUint8s().LookupModOrZero(LoadInt8x16Array(&trunc16To8Idx)) 31 } 32 33 // TruncToInt16 converts each element of x to int16 by discarding its high 34 // bits. 35 // 36 // z[i] = int16(x[i]) 37 // 38 // The results are stored in the low 4 elements of z. 39 // The remaining elements of z are zero. 40 // 41 // Emulated, CPU Feature: AVX 42 func (x Int32x4) TruncToInt16() (z Int16x8) { 43 return x.ToBits().TruncToUint16().BitsToInt16() 44 } 45 46 // TruncToUint16 converts each element of x to uint16 by discarding its high 47 // bits. 48 // 49 // z[i] = uint16(x[i]) 50 // 51 // The results are stored in the low 4 elements of z. 52 // The remaining elements of z are zero. 53 // 54 // Emulated, CPU Feature: AVX 55 func (x Uint32x4) TruncToUint16() (z Uint16x8) { 56 return x.ReshapeToUint8s().LookupModOrZero(LoadInt8x16Array(&trunc32To16Idx)).ReshapeToUint16s() 57 } 58 59 // TruncToInt32 converts each element of x to int32 by discarding its high 60 // bits. 61 // 62 // z[i] = int32(x[i]) 63 // 64 // The results are stored in the low 2 elements of z. 65 // The remaining elements of z are zero. 66 // 67 // Emulated, CPU Feature: AVX 68 func (x Int64x2) TruncToInt32() (z Int32x4) { 69 return x.ToBits().TruncToUint32().BitsToInt32() 70 } 71 72 // TruncToUint32 converts each element of x to uint32 by discarding its high 73 // bits. 74 // 75 // z[i] = uint32(x[i]) 76 // 77 // The results are stored in the low 2 elements of z. 78 // The remaining elements of z are zero. 79 // 80 // Emulated, CPU Feature: AVX 81 func (x Uint64x2) TruncToUint32() (z Uint32x4) { 82 var zero Uint32x4 83 return x.ReshapeToUint32s().ConcatPermuteScalars(0, 2, 4, 4, zero) 84 } 85 86 // TruncToInt8 converts each element of x to int8 by discarding its high 87 // bits. 88 // 89 // z[i] = int8(x[i]) 90 // 91 // The results are stored in the low 16 elements of z. 92 // The remaining elements of z are zero. 93 // 94 // Emulated, CPU Feature: AVX2 95 func (x Int16x16) TruncToInt8() (z Int8x32) { 96 return x.ToBits().TruncToUint8().BitsToInt8() 97 } 98 99 // TruncToUint8 converts each element of x to uint8 by discarding its high 100 // bits. 101 // 102 // z[i] = uint8(x[i]) 103 // 104 // The results are stored in the low 16 elements of z. 105 // The remaining elements of z are zero. 106 // 107 // Emulated, CPU Feature: AVX2 108 func (x Uint16x16) TruncToUint8() (z Uint8x32) { 109 if X86.AVX512() { 110 return x.truncToUint8() 111 } 112 g := x.ReshapeToUint8s().LookupModOrZeroGrouped(LoadInt8x32Array(&trunc16To8GroupedIdx)) 113 return gatherLo64(g.ReshapeToUint64s()).ReshapeToUint8s() 114 } 115 116 // TruncToInt16 converts each element of x to int16 by discarding its high 117 // bits. 118 // 119 // z[i] = int16(x[i]) 120 // 121 // The results are stored in the low 8 elements of z. 122 // The remaining elements of z are zero. 123 // 124 // Emulated, CPU Feature: AVX2 125 func (x Int32x8) TruncToInt16() (z Int16x16) { 126 return x.ToBits().TruncToUint16().BitsToInt16() 127 } 128 129 // TruncToUint16 converts each element of x to uint16 by discarding its high 130 // bits. 131 // 132 // z[i] = uint16(x[i]) 133 // 134 // The results are stored in the low 8 elements of z. 135 // The remaining elements of z are zero. 136 // 137 // Emulated, CPU Feature: AVX2 138 func (x Uint32x8) TruncToUint16() (z Uint16x16) { 139 if X86.AVX512() { 140 return x.truncToUint16() 141 } 142 g := x.ReshapeToUint8s().LookupModOrZeroGrouped(LoadInt8x32Array(&trunc32To16GroupedIdx)) 143 return gatherLo64(g.ReshapeToUint64s()).ReshapeToUint16s() 144 } 145 146 // TruncToInt32 converts each element of x to int32 by discarding its high 147 // bits. 148 // 149 // z[i] = int32(x[i]) 150 // 151 // The results are stored in the low 4 elements of z. 152 // The remaining elements of z are zero. 153 // 154 // Emulated, CPU Feature: AVX2 155 func (x Int64x4) TruncToInt32() (z Int32x8) { 156 return x.ToBits().TruncToUint32().BitsToInt32() 157 } 158 159 // TruncToUint32 converts each element of x to uint32 by discarding its high 160 // bits. 161 // 162 // z[i] = uint32(x[i]) 163 // 164 // The results are stored in the low 4 elements of z. 165 // The remaining elements of z are zero. 166 // 167 // Emulated, CPU Feature: AVX2 168 func (x Uint64x4) TruncToUint32() (z Uint32x8) { 169 if X86.AVX512() { 170 return x.truncToUint32() 171 } 172 var zero Uint32x8 173 g := x.ReshapeToUint32s().ConcatPermuteScalarsGrouped(0, 2, 4, 4, zero) 174 return gatherLo64(g.ReshapeToUint64s()).ReshapeToUint32s() 175 } 176 177 // SaturateToInt8 converts each element of x to int8, saturating values 178 // that are outside the range of int8. 179 // 180 // z[i] = sat(x[i]) 181 // 182 // The results are stored in the low 8 elements of z. 183 // The remaining elements of z are zero. 184 // 185 // Emulated, CPU Feature: AVX 186 func (x Int16x8) SaturateToInt8() (z Int8x16) { 187 var zero Int16x8 188 return x.concatSaturateToInt8(zero) 189 } 190 191 // SaturateToUint8 converts each element of x to uint8, saturating values 192 // that are outside the range of uint8. Negative values become 0. 193 // 194 // z[i] = sat(x[i]) 195 // 196 // The results are stored in the low 8 elements of z. 197 // The remaining elements of z are zero. 198 // 199 // Emulated, CPU Feature: AVX 200 func (x Int16x8) SaturateToUint8() (z Uint8x16) { 201 var zero Int16x8 202 return x.concatSaturateToUint8(zero) 203 } 204 205 // SaturateToUint8 converts each element of x to uint8, saturating values 206 // that are outside the range of uint8. 207 // 208 // z[i] = sat(x[i]) 209 // 210 // The results are stored in the low 8 elements of z. 211 // The remaining elements of z are zero. 212 // 213 // Emulated, CPU Feature: AVX 214 func (x Uint16x8) SaturateToUint8() (z Uint8x16) { 215 if X86.AVX512() { 216 return x.saturateToUint8() 217 } 218 // After the Min, x is non-negative as an int16, so the signed-to-unsigned 219 // saturation doesn't change it. 220 x = x.Min(LoadUint16x8Array(&maxUint8x8)) 221 return x.BitsToInt16().SaturateToUint8() 222 } 223 224 // SaturateToInt16 converts each element of x to int16, saturating values 225 // that are outside the range of int16. 226 // 227 // z[i] = sat(x[i]) 228 // 229 // The results are stored in the low 4 elements of z. 230 // The remaining elements of z are zero. 231 // 232 // Emulated, CPU Feature: AVX 233 func (x Int32x4) SaturateToInt16() (z Int16x8) { 234 var zero Int32x4 235 return x.ConcatSaturateToInt16(zero) 236 } 237 238 // SaturateToUint16 converts each element of x to uint16, saturating values 239 // that are outside the range of uint16. Negative values become 0. 240 // 241 // z[i] = sat(x[i]) 242 // 243 // The results are stored in the low 4 elements of z. 244 // The remaining elements of z are zero. 245 // 246 // Emulated, CPU Feature: AVX 247 func (x Int32x4) SaturateToUint16() (z Uint16x8) { 248 var zero Int32x4 249 return x.ConcatSaturateToUint16(zero) 250 } 251 252 // SaturateToUint16 converts each element of x to uint16, saturating values 253 // that are outside the range of uint16. 254 // 255 // z[i] = sat(x[i]) 256 // 257 // The results are stored in the low 4 elements of z. 258 // The remaining elements of z are zero. 259 // 260 // Emulated, CPU Feature: AVX 261 func (x Uint32x4) SaturateToUint16() (z Uint16x8) { 262 if X86.AVX512() { 263 return x.saturateToUint16() 264 } 265 // After the Min, x is non-negative as an int32, so the signed-to-unsigned 266 // saturation doesn't change it. 267 x = x.Min(LoadUint32x4Array(&maxUint16x4)) 268 return x.BitsToInt32().SaturateToUint16() 269 } 270 271 // SaturateToInt32 converts each element of x to int32, saturating values 272 // that are outside the range of int32. 273 // 274 // z[i] = sat(x[i]) 275 // 276 // The results are stored in the low 2 elements of z. 277 // The remaining elements of z are zero. 278 // 279 // Emulated, CPU Feature: AVX 280 func (x Int64x2) SaturateToInt32() (z Int32x4) { 281 if X86.AVX512() { 282 return x.saturateToInt32() 283 } 284 hi, lo := LoadInt64x2Array(&maxInt32x2), LoadInt64x2Array(&minInt32x2) 285 x = hi.IfElse(x.Greater(hi), x) 286 x = lo.IfElse(x.Less(lo), x) 287 return x.TruncToInt32() 288 } 289 290 // SaturateToUint32 converts each element of x to uint32, saturating values 291 // that are outside the range of uint32. Negative values become 0. 292 // 293 // z[i] = sat(x[i]) 294 // 295 // The results are stored in the low 2 elements of z. 296 // The remaining elements of z are zero. 297 // 298 // Emulated, CPU Feature: AVX 299 func (x Int64x2) SaturateToUint32() (z Uint32x4) { 300 var zero Int64x2 301 if X86.AVX512() { 302 return x.Max(zero).ToBits().saturateToUint32() 303 } 304 hi := LoadInt64x2Array(&maxUint32x2) 305 x = x.Masked(x.Greater(zero)) 306 x = hi.IfElse(x.Greater(hi), x) 307 return x.ToBits().TruncToUint32() 308 } 309 310 // SaturateToUint32 converts each element of x to uint32, saturating values 311 // that are outside the range of uint32. 312 // 313 // z[i] = sat(x[i]) 314 // 315 // The results are stored in the low 2 elements of z. 316 // The remaining elements of z are zero. 317 // 318 // Emulated, CPU Feature: AVX 319 func (x Uint64x2) SaturateToUint32() (z Uint32x4) { 320 if X86.AVX512() { 321 return x.saturateToUint32() 322 } 323 // x fits in a uint32 if its high 32 bits are zero. 324 var zero Uint64x2 325 hi := LoadInt64x2Array(&maxUint32x2).ToBits() 326 return x.IfElse(x.ShiftAllRight(32).Equal(zero), hi).TruncToUint32() 327 } 328 329 // SaturateToInt8 converts each element of x to int8, saturating values 330 // that are outside the range of int8. 331 // 332 // z[i] = sat(x[i]) 333 // 334 // The results are stored in the low 16 elements of z. 335 // The remaining elements of z are zero. 336 // 337 // Emulated, CPU Feature: AVX2 338 func (x Int16x16) SaturateToInt8() (z Int8x32) { 339 if X86.AVX512() { 340 return x.saturateToInt8() 341 } 342 var zero Int16x16 343 g := x.concatSaturateToInt8Grouped(zero) 344 return gatherLo64(g.ToBits().ReshapeToUint64s()).ReshapeToUint8s().BitsToInt8() 345 } 346 347 // SaturateToUint8 converts each element of x to uint8, saturating values 348 // that are outside the range of uint8. Negative values become 0. 349 // 350 // z[i] = sat(x[i]) 351 // 352 // The results are stored in the low 16 elements of z. 353 // The remaining elements of z are zero. 354 // 355 // Emulated, CPU Feature: AVX2 356 func (x Int16x16) SaturateToUint8() (z Uint8x32) { 357 var zero Int16x16 358 g := x.concatSaturateToUint8Grouped(zero) 359 return gatherLo64(g.ReshapeToUint64s()).ReshapeToUint8s() 360 } 361 362 // SaturateToUint8 converts each element of x to uint8, saturating values 363 // that are outside the range of uint8. 364 // 365 // z[i] = sat(x[i]) 366 // 367 // The results are stored in the low 16 elements of z. 368 // The remaining elements of z are zero. 369 // 370 // Emulated, CPU Feature: AVX2 371 func (x Uint16x16) SaturateToUint8() (z Uint8x32) { 372 if X86.AVX512() { 373 return x.saturateToUint8() 374 } 375 // After the Min, x is non-negative as an int16, so the signed-to-unsigned 376 // saturation doesn't change it. 377 x = x.Min(LoadUint16x16Array(&maxUint8x16)) 378 return x.BitsToInt16().SaturateToUint8() 379 } 380 381 // SaturateToInt16 converts each element of x to int16, saturating values 382 // that are outside the range of int16. 383 // 384 // z[i] = sat(x[i]) 385 // 386 // The results are stored in the low 8 elements of z. 387 // The remaining elements of z are zero. 388 // 389 // Emulated, CPU Feature: AVX2 390 func (x Int32x8) SaturateToInt16() (z Int16x16) { 391 if X86.AVX512() { 392 return x.saturateToInt16() 393 } 394 var zero Int32x8 395 g := x.ConcatSaturateToInt16Grouped(zero) 396 return gatherLo64(g.ToBits().ReshapeToUint64s()).ReshapeToUint16s().BitsToInt16() 397 } 398 399 // SaturateToUint16 converts each element of x to uint16, saturating values 400 // that are outside the range of uint16. Negative values become 0. 401 // 402 // z[i] = sat(x[i]) 403 // 404 // The results are stored in the low 8 elements of z. 405 // The remaining elements of z are zero. 406 // 407 // Emulated, CPU Feature: AVX2 408 func (x Int32x8) SaturateToUint16() (z Uint16x16) { 409 var zero Int32x8 410 g := x.ConcatSaturateToUint16Grouped(zero) 411 return gatherLo64(g.ReshapeToUint64s()).ReshapeToUint16s() 412 } 413 414 // SaturateToUint16 converts each element of x to uint16, saturating values 415 // that are outside the range of uint16. 416 // 417 // z[i] = sat(x[i]) 418 // 419 // The results are stored in the low 8 elements of z. 420 // The remaining elements of z are zero. 421 // 422 // Emulated, CPU Feature: AVX2 423 func (x Uint32x8) SaturateToUint16() (z Uint16x16) { 424 if X86.AVX512() { 425 return x.saturateToUint16() 426 } 427 // After the Min, x is non-negative as an int32, so the signed-to-unsigned 428 // saturation doesn't change it. 429 x = x.Min(LoadUint32x8Array(&maxUint16x8)) 430 return x.BitsToInt32().SaturateToUint16() 431 } 432 433 // SaturateToInt32 converts each element of x to int32, saturating values 434 // that are outside the range of int32. 435 // 436 // z[i] = sat(x[i]) 437 // 438 // The results are stored in the low 4 elements of z. 439 // The remaining elements of z are zero. 440 // 441 // Emulated, CPU Feature: AVX2 442 func (x Int64x4) SaturateToInt32() (z Int32x8) { 443 if X86.AVX512() { 444 return x.saturateToInt32() 445 } 446 hi, lo := LoadInt64x4Array(&maxInt32x4), LoadInt64x4Array(&minInt32x4) 447 x = hi.IfElse(x.Greater(hi), x) 448 x = lo.IfElse(x.Less(lo), x) 449 return x.TruncToInt32() 450 } 451 452 // SaturateToUint32 converts each element of x to uint32, saturating values 453 // that are outside the range of uint32. Negative values become 0. 454 // 455 // z[i] = sat(x[i]) 456 // 457 // The results are stored in the low 4 elements of z. 458 // The remaining elements of z are zero. 459 // 460 // Emulated, CPU Feature: AVX2 461 func (x Int64x4) SaturateToUint32() (z Uint32x8) { 462 var zero Int64x4 463 if X86.AVX512() { 464 return x.Max(zero).ToBits().saturateToUint32() 465 } 466 hi := LoadInt64x4Array(&maxUint32x4) 467 x = x.Masked(x.Greater(zero)) 468 x = hi.IfElse(x.Greater(hi), x) 469 return x.ToBits().TruncToUint32() 470 } 471 472 // SaturateToUint32 converts each element of x to uint32, saturating values 473 // that are outside the range of uint32. 474 // 475 // z[i] = sat(x[i]) 476 // 477 // The results are stored in the low 4 elements of z. 478 // The remaining elements of z are zero. 479 // 480 // Emulated, CPU Feature: AVX2 481 func (x Uint64x4) SaturateToUint32() (z Uint32x8) { 482 if X86.AVX512() { 483 return x.saturateToUint32() 484 } 485 // x fits in a uint32 if its high 32 bits are zero. 486 var zero Uint64x4 487 hi := LoadInt64x4Array(&maxUint32x4).ToBits() 488 return x.IfElse(x.ShiftAllRight(32).Equal(zero), hi).TruncToUint32() 489 } 490 491 // SaturateToUint8 converts each element of x to uint8, saturating values 492 // that are outside the range of uint8. Negative values become 0. 493 // 494 // z[i] = sat(x[i]) 495 // 496 // The results are stored in the low 32 elements of z. 497 // The remaining elements of z are zero. 498 // 499 // Emulated, CPU Feature: AVX512 500 func (x Int16x32) SaturateToUint8() (z Uint8x64) { 501 var zero Int16x32 502 return x.Max(zero).ToBits().SaturateToUint8() 503 } 504 505 // SaturateToUint8 converts each element of x to uint8, saturating values 506 // that are outside the range of uint8. Negative values become 0. 507 // 508 // z[i] = sat(x[i]) 509 // 510 // The results are stored in the low 4 elements of z. 511 // The remaining elements of z are zero. 512 // 513 // Emulated, CPU Feature: AVX512 514 func (x Int32x4) SaturateToUint8() (z Uint8x16) { 515 var zero Int32x4 516 return x.Max(zero).ToBits().SaturateToUint8() 517 } 518 519 // SaturateToUint8 converts each element of x to uint8, saturating values 520 // that are outside the range of uint8. Negative values become 0. 521 // 522 // z[i] = sat(x[i]) 523 // 524 // The results are stored in the low 8 elements of z. 525 // The remaining elements of z are zero. 526 // 527 // Emulated, CPU Feature: AVX512 528 func (x Int32x8) SaturateToUint8() (z Uint8x32) { 529 var zero Int32x8 530 return x.Max(zero).ToBits().SaturateToUint8() 531 } 532 533 // SaturateToUint8 converts each element of x to uint8, saturating values 534 // that are outside the range of uint8. Negative values become 0. 535 // 536 // z[i] = sat(x[i]) 537 // 538 // The results are stored in the low 16 elements of z. 539 // The remaining elements of z are zero. 540 // 541 // Emulated, CPU Feature: AVX512 542 func (x Int32x16) SaturateToUint8() (z Uint8x64) { 543 var zero Int32x16 544 return x.Max(zero).ToBits().SaturateToUint8() 545 } 546 547 // SaturateToUint8 converts each element of x to uint8, saturating values 548 // that are outside the range of uint8. Negative values become 0. 549 // 550 // z[i] = sat(x[i]) 551 // 552 // The results are stored in the low 2 elements of z. 553 // The remaining elements of z are zero. 554 // 555 // Emulated, CPU Feature: AVX512 556 func (x Int64x2) SaturateToUint8() (z Uint8x16) { 557 var zero Int64x2 558 return x.Max(zero).ToBits().SaturateToUint8() 559 } 560 561 // SaturateToUint8 converts each element of x to uint8, saturating values 562 // that are outside the range of uint8. Negative values become 0. 563 // 564 // z[i] = sat(x[i]) 565 // 566 // The results are stored in the low 4 elements of z. 567 // The remaining elements of z are zero. 568 // 569 // Emulated, CPU Feature: AVX512 570 func (x Int64x4) SaturateToUint8() (z Uint8x32) { 571 var zero Int64x4 572 return x.Max(zero).ToBits().SaturateToUint8() 573 } 574 575 // SaturateToUint8 converts each element of x to uint8, saturating values 576 // that are outside the range of uint8. Negative values become 0. 577 // 578 // z[i] = sat(x[i]) 579 // 580 // The results are stored in the low 8 elements of z. 581 // The remaining elements of z are zero. 582 // 583 // Emulated, CPU Feature: AVX512 584 func (x Int64x8) SaturateToUint8() (z Uint8x64) { 585 var zero Int64x8 586 return x.Max(zero).ToBits().SaturateToUint8() 587 } 588 589 // SaturateToUint16 converts each element of x to uint16, saturating values 590 // that are outside the range of uint16. Negative values become 0. 591 // 592 // z[i] = sat(x[i]) 593 // 594 // The results are stored in the low 16 elements of z. 595 // The remaining elements of z are zero. 596 // 597 // Emulated, CPU Feature: AVX512 598 func (x Int32x16) SaturateToUint16() (z Uint16x32) { 599 var zero Int32x16 600 return x.Max(zero).ToBits().SaturateToUint16() 601 } 602 603 // SaturateToUint16 converts each element of x to uint16, saturating values 604 // that are outside the range of uint16. Negative values become 0. 605 // 606 // z[i] = sat(x[i]) 607 // 608 // The results are stored in the low 2 elements of z. 609 // The remaining elements of z are zero. 610 // 611 // Emulated, CPU Feature: AVX512 612 func (x Int64x2) SaturateToUint16() (z Uint16x8) { 613 var zero Int64x2 614 return x.Max(zero).ToBits().SaturateToUint16() 615 } 616 617 // SaturateToUint16 converts each element of x to uint16, saturating values 618 // that are outside the range of uint16. Negative values become 0. 619 // 620 // z[i] = sat(x[i]) 621 // 622 // The results are stored in the low 4 elements of z. 623 // The remaining elements of z are zero. 624 // 625 // Emulated, CPU Feature: AVX512 626 func (x Int64x4) SaturateToUint16() (z Uint16x16) { 627 var zero Int64x4 628 return x.Max(zero).ToBits().SaturateToUint16() 629 } 630 631 // SaturateToUint16 converts each element of x to uint16, saturating values 632 // that are outside the range of uint16. Negative values become 0. 633 // 634 // z[i] = sat(x[i]) 635 // 636 // The results are stored in the low 8 elements of z. 637 // The remaining elements of z are zero. 638 // 639 // Emulated, CPU Feature: AVX512 640 func (x Int64x8) SaturateToUint16() (z Uint16x32) { 641 var zero Int64x8 642 return x.Max(zero).ToBits().SaturateToUint16() 643 } 644 645 // SaturateToUint32 converts each element of x to uint32, saturating values 646 // that are outside the range of uint32. Negative values become 0. 647 // 648 // z[i] = sat(x[i]) 649 // 650 // The results are stored in the low 8 elements of z. 651 // The remaining elements of z are zero. 652 // 653 // Emulated, CPU Feature: AVX512 654 func (x Int64x8) SaturateToUint32() (z Uint32x16) { 655 var zero Int64x8 656 return x.Max(zero).ToBits().SaturateToUint32() 657 } 658