sse-builtins.c 27.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809
// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse -emit-llvm -o - -Wall -Werror | FileCheck %s
// RUN: %clang_cc1 -fms-extensions -fms-compatibility -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse -emit-llvm -o - -Wall -Werror | FileCheck %s


#include <immintrin.h>

// NOTE: This should match the tests in llvm/test/CodeGen/X86/sse-intrinsics-fast-isel.ll

__m128 test_mm_add_ps(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_add_ps
  // CHECK: fadd <4 x float>
  return _mm_add_ps(A, B);
}

__m128 test_mm_add_ss(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_add_ss
  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
  // CHECK: fadd float
  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 0
  return _mm_add_ss(A, B);
}

__m128 test_mm_and_ps(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_and_ps
  // CHECK: and <4 x i32>
  return _mm_and_ps(A, B);
}

__m128 test_mm_andnot_ps(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_andnot_ps
  // CHECK: xor <4 x i32> %{{.*}}, <i32 -1, i32 -1, i32 -1, i32 -1>
  // CHECK: and <4 x i32>
  return _mm_andnot_ps(A, B);
}

__m128 test_mm_cmpeq_ps(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpeq_ps
  // CHECK:         [[CMP:%.*]] = fcmp oeq <4 x float>
  // CHECK-NEXT:    [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
  // CHECK-NEXT:    [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
  // CHECK-NEXT:    ret <4 x float> [[BC]]
  return _mm_cmpeq_ps(__a, __b);
}

__m128 test_mm_cmpeq_ss(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpeq_ss
  // CHECK: @llvm.x86.sse.cmp.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 0)
  return _mm_cmpeq_ss(__a, __b);
}

__m128 test_mm_cmpge_ps(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpge_ps
  // CHECK:         [[CMP:%.*]] = fcmp ole <4 x float>
  // CHECK-NEXT:    [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
  // CHECK-NEXT:    [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
  // CHECK-NEXT:    ret <4 x float> [[BC]]
  return _mm_cmpge_ps(__a, __b);
}

__m128 test_mm_cmpge_ss(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpge_ss
  // CHECK: @llvm.x86.sse.cmp.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 2)
  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
  return _mm_cmpge_ss(__a, __b);
}

__m128 test_mm_cmpgt_ps(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpgt_ps
  // CHECK:         [[CMP:%.*]] = fcmp olt <4 x float>
  // CHECK-NEXT:    [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
  // CHECK-NEXT:    [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
  // CHECK-NEXT:    ret <4 x float> [[BC]]
  return _mm_cmpgt_ps(__a, __b);
}

__m128 test_mm_cmpgt_ss(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpgt_ss
  // CHECK: @llvm.x86.sse.cmp.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 1)
  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
  return _mm_cmpgt_ss(__a, __b);
}

__m128 test_mm_cmple_ps(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmple_ps
  // CHECK:         [[CMP:%.*]] = fcmp ole <4 x float>
  // CHECK-NEXT:    [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
  // CHECK-NEXT:    [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
  // CHECK-NEXT:    ret <4 x float> [[BC]]
  return _mm_cmple_ps(__a, __b);
}

__m128 test_mm_cmple_ss(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmple_ss
  // CHECK: @llvm.x86.sse.cmp.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 2)
  return _mm_cmple_ss(__a, __b);
}

__m128 test_mm_cmplt_ps(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmplt_ps
  // CHECK:         [[CMP:%.*]] = fcmp olt <4 x float>
  // CHECK-NEXT:    [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
  // CHECK-NEXT:    [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
  // CHECK-NEXT:    ret <4 x float> [[BC]]
  return _mm_cmplt_ps(__a, __b);
}

__m128 test_mm_cmplt_ss(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmplt_ss
  // CHECK: @llvm.x86.sse.cmp.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 1)
  return _mm_cmplt_ss(__a, __b);
}

__m128 test_mm_cmpneq_ps(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpneq_ps
  // CHECK:         [[CMP:%.*]] = fcmp une <4 x float>
  // CHECK-NEXT:    [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
  // CHECK-NEXT:    [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
  // CHECK-NEXT:    ret <4 x float> [[BC]]
  return _mm_cmpneq_ps(__a, __b);
}

__m128 test_mm_cmpneq_ss(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpneq_ss
  // CHECK: @llvm.x86.sse.cmp.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 4)
  return _mm_cmpneq_ss(__a, __b);
}

__m128 test_mm_cmpnge_ps(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpnge_ps
  // CHECK:         [[CMP:%.*]] = fcmp ugt <4 x float>
  // CHECK-NEXT:    [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
  // CHECK-NEXT:    [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
  // CHECK-NEXT:    ret <4 x float> [[BC]]
  return _mm_cmpnge_ps(__a, __b);
}

__m128 test_mm_cmpnge_ss(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpnge_ss
  // CHECK: @llvm.x86.sse.cmp.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 6)
  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
  return _mm_cmpnge_ss(__a, __b);
}

__m128 test_mm_cmpngt_ps(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpngt_ps
  // CHECK:         [[CMP:%.*]] = fcmp uge <4 x float>
  // CHECK-NEXT:    [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
  // CHECK-NEXT:    [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
  // CHECK-NEXT:    ret <4 x float> [[BC]]
  return _mm_cmpngt_ps(__a, __b);
}

__m128 test_mm_cmpngt_ss(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpngt_ss
  // CHECK: @llvm.x86.sse.cmp.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 5)
  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
  return _mm_cmpngt_ss(__a, __b);
}

__m128 test_mm_cmpnle_ps(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpnle_ps
  // CHECK:         [[CMP:%.*]] = fcmp ugt <4 x float>
  // CHECK-NEXT:    [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
  // CHECK-NEXT:    [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
  // CHECK-NEXT:    ret <4 x float> [[BC]]
  return _mm_cmpnle_ps(__a, __b);
}

__m128 test_mm_cmpnle_ss(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpnle_ss
  // CHECK: @llvm.x86.sse.cmp.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 6)
  return _mm_cmpnle_ss(__a, __b);
}

__m128 test_mm_cmpnlt_ps(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpnlt_ps
  // CHECK:         [[CMP:%.*]] = fcmp uge <4 x float>
  // CHECK-NEXT:    [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
  // CHECK-NEXT:    [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
  // CHECK-NEXT:    ret <4 x float> [[BC]]
  return _mm_cmpnlt_ps(__a, __b);
}

__m128 test_mm_cmpnlt_ss(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpnlt_ss
  // CHECK: @llvm.x86.sse.cmp.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 5)
  return _mm_cmpnlt_ss(__a, __b);
}

__m128 test_mm_cmpord_ps(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpord_ps
  // CHECK:         [[CMP:%.*]] = fcmp ord <4 x float>
  // CHECK-NEXT:    [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
  // CHECK-NEXT:    [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
  // CHECK-NEXT:    ret <4 x float> [[BC]]
  return _mm_cmpord_ps(__a, __b);
}

__m128 test_mm_cmpord_ss(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpord_ss
  // CHECK: @llvm.x86.sse.cmp.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 7)
  return _mm_cmpord_ss(__a, __b);
}

__m128 test_mm_cmpunord_ps(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpunord_ps
  // CHECK:         [[CMP:%.*]] = fcmp uno <4 x float>
  // CHECK-NEXT:    [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
  // CHECK-NEXT:    [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
  // CHECK-NEXT:    ret <4 x float> [[BC]]
  return _mm_cmpunord_ps(__a, __b);
}

__m128 test_mm_cmpunord_ss(__m128 __a, __m128 __b) {
  // CHECK-LABEL: @test_mm_cmpunord_ss
  // CHECK: @llvm.x86.sse.cmp.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 3)
  return _mm_cmpunord_ss(__a, __b);
}

int test_mm_comieq_ss(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_comieq_ss
  // CHECK: call i32 @llvm.x86.sse.comieq.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}})
  return _mm_comieq_ss(A, B);
}

int test_mm_comige_ss(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_comige_ss
  // CHECK: call i32 @llvm.x86.sse.comige.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}})
  return _mm_comige_ss(A, B);
}

int test_mm_comigt_ss(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_comigt_ss
  // CHECK: call i32 @llvm.x86.sse.comigt.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}})
  return _mm_comigt_ss(A, B);
}

int test_mm_comile_ss(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_comile_ss
  // CHECK: call i32 @llvm.x86.sse.comile.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}})
  return _mm_comile_ss(A, B);
}

int test_mm_comilt_ss(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_comilt_ss
  // CHECK: call i32 @llvm.x86.sse.comilt.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}})
  return _mm_comilt_ss(A, B);
}

int test_mm_comineq_ss(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_comineq_ss
  // CHECK: call i32 @llvm.x86.sse.comineq.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}})
  return _mm_comineq_ss(A, B);
}

int test_mm_cvt_ss2si(__m128 A) {
  // CHECK-LABEL: test_mm_cvt_ss2si
  // CHECK: call i32 @llvm.x86.sse.cvtss2si(<4 x float> %{{.*}})
  return _mm_cvt_ss2si(A);
}

__m128 test_mm_cvtsi32_ss(__m128 A, int B) {
  // CHECK-LABEL: test_mm_cvtsi32_ss
  // CHECK: sitofp i32 %{{.*}} to float
  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 0
  return _mm_cvtsi32_ss(A, B);
}

#ifdef __x86_64__
__m128 test_mm_cvtsi64_ss(__m128 A, long long B) {
  // CHECK-LABEL: test_mm_cvtsi64_ss
  // CHECK: sitofp i64 %{{.*}} to float
  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 0
  return _mm_cvtsi64_ss(A, B);
}
#endif

float test_mm_cvtss_f32(__m128 A) {
  // CHECK-LABEL: test_mm_cvtss_f32
  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
  return _mm_cvtss_f32(A);
}

int test_mm_cvtss_si32(__m128 A) {
  // CHECK-LABEL: test_mm_cvtss_si32
  // CHECK: call i32 @llvm.x86.sse.cvtss2si(<4 x float> %{{.*}})
  return _mm_cvtss_si32(A);
}

#ifdef __x86_64__
long long test_mm_cvtss_si64(__m128 A) {
  // CHECK-LABEL: test_mm_cvtss_si64
  // CHECK: call i64 @llvm.x86.sse.cvtss2si64(<4 x float> %{{.*}})
  return _mm_cvtss_si64(A);
}
#endif

int test_mm_cvtt_ss2si(__m128 A) {
  // CHECK-LABEL: test_mm_cvtt_ss2si
  // CHECK: call i32 @llvm.x86.sse.cvttss2si(<4 x float> %{{.*}})
  return _mm_cvtt_ss2si(A);
}

int test_mm_cvttss_si32(__m128 A) {
  // CHECK-LABEL: test_mm_cvttss_si32
  // CHECK: call i32 @llvm.x86.sse.cvttss2si(<4 x float> %{{.*}})
  return _mm_cvttss_si32(A);
}

#ifdef __x86_64__
long long test_mm_cvttss_si64(__m128 A) {
  // CHECK-LABEL: test_mm_cvttss_si64
  // CHECK: call i64 @llvm.x86.sse.cvttss2si64(<4 x float> %{{.*}})
  return _mm_cvttss_si64(A);
}
#endif

__m128 test_mm_div_ps(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_div_ps
  // CHECK: fdiv <4 x float>
  return _mm_div_ps(A, B);
}

__m128 test_mm_div_ss(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_div_ss
  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
  // CHECK: fdiv float
  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 0
  return _mm_div_ss(A, B);
}

unsigned int test_MM_GET_EXCEPTION_MASK() {
  // CHECK-LABEL: test_MM_GET_EXCEPTION_MASK
  // CHECK: call void @llvm.x86.sse.stmxcsr(i8* %{{.*}})
  // CHECK: and i32 %{{.*}}, 8064
  return _MM_GET_EXCEPTION_MASK();
}

unsigned int test_MM_GET_EXCEPTION_STATE() {
  // CHECK-LABEL: test_MM_GET_EXCEPTION_STATE
  // CHECK: call void @llvm.x86.sse.stmxcsr(i8* %{{.*}})
  // CHECK: and i32 %{{.*}}, 63
  return _MM_GET_EXCEPTION_STATE();
}

unsigned int test_MM_GET_FLUSH_ZERO_MODE() {
  // CHECK-LABEL: test_MM_GET_FLUSH_ZERO_MODE
  // CHECK: call void @llvm.x86.sse.stmxcsr(i8* %{{.*}})
  // CHECK: and i32 %{{.*}}, 32768
  return _MM_GET_FLUSH_ZERO_MODE();
}

unsigned int test_MM_GET_ROUNDING_MODE() {
  // CHECK-LABEL: test_MM_GET_ROUNDING_MODE
  // CHECK: call void @llvm.x86.sse.stmxcsr(i8* %{{.*}})
  // CHECK: and i32 %{{.*}}, 24576
  return _MM_GET_ROUNDING_MODE();
}

unsigned int test_mm_getcsr() {
  // CHECK-LABEL: test_mm_getcsr
  // CHECK: call void @llvm.x86.sse.stmxcsr(i8* %{{.*}})
  // CHECK: load i32
  return _mm_getcsr();
}

__m128 test_mm_load_ps(float* y) {
  // CHECK-LABEL: test_mm_load_ps
  // CHECK: load <4 x float>, <4 x float>* {{.*}}, align 16
  return _mm_load_ps(y);
}

__m128 test_mm_load_ps1(float* y) {
  // CHECK-LABEL: test_mm_load_ps1
  // CHECK: load float, float* %{{.*}}, align 4
  // CHECK: insertelement <4 x float> undef, float %{{.*}}, i32 0
  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 1
  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 2
  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 3
  return _mm_load_ps1(y);
}

__m128 test_mm_load_ss(float* y) {
  // CHECK-LABEL: test_mm_load_ss
  // CHECK: load float, float* {{.*}}, align 1{{$}}
  // CHECK: insertelement <4 x float> undef, float %{{.*}}, i32 0
  // CHECK: insertelement <4 x float> %{{.*}}, float 0.000000e+00, i32 1
  // CHECK: insertelement <4 x float> %{{.*}}, float 0.000000e+00, i32 2
  // CHECK: insertelement <4 x float> %{{.*}}, float 0.000000e+00, i32 3
  return _mm_load_ss(y);
}

__m128 test_mm_load1_ps(float* y) {
  // CHECK-LABEL: test_mm_load1_ps
  // CHECK: load float, float* %{{.*}}, align 4
  // CHECK: insertelement <4 x float> undef, float %{{.*}}, i32 0
  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 1
  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 2
  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 3
  return _mm_load1_ps(y);
}

__m128 test_mm_loadh_pi(__m128 x, __m64* y) {
  // CHECK-LABEL: test_mm_loadh_pi
  // CHECK: load <2 x float>, <2 x float>* {{.*}}, align 1{{$}}
  // CHECK: shufflevector {{.*}} <4 x i32> <i32 0, i32 1
  // CHECK: shufflevector {{.*}} <4 x i32> <i32 0, i32 1, i32 4, i32 5>
  return _mm_loadh_pi(x,y);
}

__m128 test_mm_loadl_pi(__m128 x, __m64* y) {
  // CHECK-LABEL: test_mm_loadl_pi
  // CHECK: load <2 x float>, <2 x float>* {{.*}}, align 1{{$}}
  // CHECK: shufflevector {{.*}} <4 x i32> <i32 0, i32 1
  // CHECK: shufflevector {{.*}} <4 x i32> <i32 4, i32 5, i32 2, i32 3>
  return _mm_loadl_pi(x,y);
}

__m128 test_mm_loadr_ps(float* A) {
  // CHECK-LABEL: test_mm_loadr_ps
  // CHECK: load <4 x float>, <4 x float>* %{{.*}}, align 16
  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
  return _mm_loadr_ps(A);
}

__m128 test_mm_loadu_ps(float* A) {
  // CHECK-LABEL: test_mm_loadu_ps
  // CHECK: load <4 x float>, <4 x float>* %{{.*}}, align 1{{$}}
  return _mm_loadu_ps(A);
}

__m128 test_mm_max_ps(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_max_ps
  // CHECK: @llvm.x86.sse.max.ps(<4 x float> %{{.*}}, <4 x float> %{{.*}})
  return _mm_max_ps(A, B);
}

__m128 test_mm_max_ss(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_max_ss
  // CHECK: @llvm.x86.sse.max.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}})
  return _mm_max_ss(A, B);
}

__m128 test_mm_min_ps(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_min_ps
  // CHECK: @llvm.x86.sse.min.ps(<4 x float> %{{.*}}, <4 x float> %{{.*}})
  return _mm_min_ps(A, B);
}

__m128 test_mm_min_ss(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_min_ss
  // CHECK: @llvm.x86.sse.min.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}})
  return _mm_min_ss(A, B);
}

__m128 test_mm_move_ss(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_move_ss
  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 0
  return _mm_move_ss(A, B);
}

__m128 test_mm_movehl_ps(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_movehl_ps
  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> <i32 6, i32 7, i32 2, i32 3>
  return _mm_movehl_ps(A, B);
}

__m128 test_mm_movelh_ps(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_movelh_ps
  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
  return _mm_movelh_ps(A, B);
}

int test_mm_movemask_ps(__m128 A) {
  // CHECK-LABEL: test_mm_movemask_ps
  // CHECK: call i32 @llvm.x86.sse.movmsk.ps(<4 x float> %{{.*}})
  return _mm_movemask_ps(A);
}

__m128 test_mm_mul_ps(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_mul_ps
  // CHECK: fmul <4 x float>
  return _mm_mul_ps(A, B);
}

__m128 test_mm_mul_ss(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_mul_ss
  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
  // CHECK: fmul float
  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 0
  return _mm_mul_ss(A, B);
}

__m128 test_mm_or_ps(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_or_ps
  // CHECK: or <4 x i32>
  return _mm_or_ps(A, B);
}

void test_mm_prefetch(char const* p) {
  // CHECK-LABEL: test_mm_prefetch
  // CHECK: call void @llvm.prefetch.p0i8(i8* {{.*}}, i32 0, i32 0, i32 1)
  _mm_prefetch(p, 0);
}

__m128 test_mm_rcp_ps(__m128 x) {
  // CHECK-LABEL: test_mm_rcp_ps
  // CHECK: call <4 x float> @llvm.x86.sse.rcp.ps(<4 x float> {{.*}})
  return _mm_rcp_ps(x);
}

__m128 test_mm_rcp_ss(__m128 x) {
  // CHECK-LABEL: test_mm_rcp_ss
  // CHECK: call <4 x float> @llvm.x86.sse.rcp.ss(<4 x float> {{.*}})
  return _mm_rcp_ss(x);
}

__m128 test_mm_rsqrt_ps(__m128 x) {
  // CHECK-LABEL: test_mm_rsqrt_ps
  // CHECK: call <4 x float> @llvm.x86.sse.rsqrt.ps(<4 x float> {{.*}})
  return _mm_rsqrt_ps(x);
}

__m128 test_mm_rsqrt_ss(__m128 x) {
  // CHECK-LABEL: test_mm_rsqrt_ss
  // CHECK: call <4 x float> @llvm.x86.sse.rsqrt.ss(<4 x float> {{.*}})
  return _mm_rsqrt_ss(x);
}

void test_MM_SET_EXCEPTION_MASK(unsigned int A) {
  // CHECK-LABEL: test_MM_SET_EXCEPTION_MASK
  // CHECK: call void @llvm.x86.sse.stmxcsr(i8* {{.*}})
  // CHECK: load i32
  // CHECK: and i32 {{.*}}, -8065
  // CHECK: or i32
  // CHECK: store i32
  // CHECK: call void @llvm.x86.sse.ldmxcsr(i8* {{.*}})
  _MM_SET_EXCEPTION_MASK(A);
}

void test_MM_SET_EXCEPTION_STATE(unsigned int A) {
  // CHECK-LABEL: test_MM_SET_EXCEPTION_STATE
  // CHECK: call void @llvm.x86.sse.stmxcsr(i8* {{.*}})
  // CHECK: load i32
  // CHECK: and i32 {{.*}}, -64
  // CHECK: or i32
  // CHECK: store i32
  // CHECK: call void @llvm.x86.sse.ldmxcsr(i8* {{.*}})
  _MM_SET_EXCEPTION_STATE(A);
}

void test_MM_SET_FLUSH_ZERO_MODE(unsigned int A) {
  // CHECK-LABEL: test_MM_SET_FLUSH_ZERO_MODE
  // CHECK: call void @llvm.x86.sse.stmxcsr(i8* {{.*}})
  // CHECK: load i32
  // CHECK: and i32 {{.*}}, -32769
  // CHECK: or i32
  // CHECK: store i32
  // CHECK: call void @llvm.x86.sse.ldmxcsr(i8* {{.*}})
  _MM_SET_FLUSH_ZERO_MODE(A);
}

__m128 test_mm_set_ps(float A, float B, float C, float D) {
  // CHECK-LABEL: test_mm_set_ps
  // CHECK: insertelement <4 x float> undef, float {{.*}}, i32 0
  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 1
  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 2
  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 3
  return _mm_set_ps(A, B, C, D);
}

__m128 test_mm_set_ps1(float A) {
  // CHECK-LABEL: test_mm_set_ps1
  // CHECK: insertelement <4 x float> undef, float {{.*}}, i32 0
  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 1
  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 2
  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 3
  return _mm_set_ps1(A);
}

void test_MM_SET_ROUNDING_MODE(unsigned int A) {
  // CHECK-LABEL: test_MM_SET_ROUNDING_MODE
  // CHECK: call void @llvm.x86.sse.stmxcsr(i8* {{.*}})
  // CHECK: load i32
  // CHECK: and i32 {{.*}}, -24577
  // CHECK: or i32
  // CHECK: store i32
  // CHECK: call void @llvm.x86.sse.ldmxcsr(i8* {{.*}})
  _MM_SET_ROUNDING_MODE(A);
}

__m128 test_mm_set_ss(float A) {
  // CHECK-LABEL: test_mm_set_ss
  // CHECK: insertelement <4 x float> undef, float {{.*}}, i32 0
  // CHECK: insertelement <4 x float> {{.*}}, float 0.000000e+00, i32 1
  // CHECK: insertelement <4 x float> {{.*}}, float 0.000000e+00, i32 2
  // CHECK: insertelement <4 x float> {{.*}}, float 0.000000e+00, i32 3
  return _mm_set_ss(A);
}

__m128 test_mm_set1_ps(float A) {
  // CHECK-LABEL: test_mm_set1_ps
  // CHECK: insertelement <4 x float> undef, float {{.*}}, i32 0
  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 1
  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 2
  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 3
  return _mm_set1_ps(A);
}

void test_mm_setcsr(unsigned int A) {
  // CHECK-LABEL: test_mm_setcsr
  // CHECK: store i32
  // CHECK: call void @llvm.x86.sse.ldmxcsr(i8* {{.*}})
  _mm_setcsr(A);
}

__m128 test_mm_setr_ps(float A, float B, float C, float D) {
  // CHECK-LABEL: test_mm_setr_ps
  // CHECK: insertelement <4 x float> undef, float {{.*}}, i32 0
  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 1
  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 2
  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 3
  return _mm_setr_ps(A, B, C, D);
}

__m128 test_mm_setzero_ps() {
  // CHECK-LABEL: test_mm_setzero_ps
  // CHECK: store <4 x float> zeroinitializer
  return _mm_setzero_ps();
}

void test_mm_sfence() {
  // CHECK-LABEL: test_mm_sfence
  // CHECK: call void @llvm.x86.sse.sfence()
  _mm_sfence();
}

__m128 test_mm_shuffle_ps(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_shuffle_ps
  // CHECK: shufflevector <4 x float> {{.*}}, <4 x float> {{.*}}, <4 x i32> <i32 0, i32 0, i32 4, i32 4>
  return _mm_shuffle_ps(A, B, 0);
}

__m128 test_mm_sqrt_ps(__m128 x) {
  // CHECK-LABEL: test_mm_sqrt_ps
  // CHECK: call <4 x float> @llvm.sqrt.v4f32(<4 x float> {{.*}})
  return _mm_sqrt_ps(x);
}

__m128 test_sqrt_ss(__m128 x) {
  // CHECK: define {{.*}} @test_sqrt_ss
  // CHECK: extractelement <4 x float> {{.*}}, i64 0
  // CHECK: call float @llvm.sqrt.f32(float {{.*}})
  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i64 0
  return _mm_sqrt_ss(x);
}

void test_mm_store_ps(float* x, __m128 y) {
  // CHECK-LABEL: test_mm_store_ps
  // CHECK: store <4 x float> %{{.*}}, <4 x float>* {{.*}}, align 16
  _mm_store_ps(x, y);
}

void test_mm_store_ps1(float* x, __m128 y) {
  // CHECK-LABEL: test_mm_store_ps1
  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> zeroinitializer
  // CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 16
  _mm_store_ps1(x, y);
}

void test_mm_store_ss(float* x, __m128 y) {
  // CHECK-LABEL: test_mm_store_ss
  // CHECK: extractelement <4 x float> {{.*}}, i32 0
  // CHECK: store float %{{.*}}, float* {{.*}}, align 1{{$}}
  _mm_store_ss(x, y);
}

void test_mm_store1_ps(float* x, __m128 y) {
  // CHECK-LABEL: test_mm_store1_ps
  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> zeroinitializer
  // CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 16
  _mm_store1_ps(x, y);
}

void test_mm_storeh_pi(__m64* x,  __m128 y) {
  // CHECK-LABEL: test_mm_storeh_pi
  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <2 x i32> <i32 2, i32 3>
  // CHECK: store <2 x float> %{{.*}}, <2 x float>* %{{.*}}, align 1{{$}}
  _mm_storeh_pi(x, y);
}

void test_mm_storel_pi(__m64* x,  __m128 y) {
  // CHECK-LABEL: test_mm_storel_pi
  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <2 x i32> <i32 0, i32 1>
  // CHECK: store <2 x float> %{{.*}}, <2 x float>* %{{.*}}, align 1{{$}}
  _mm_storel_pi(x, y);
}

void test_mm_storer_ps(float* x,  __m128 y) {
  // CHECK-LABEL: test_mm_storer_ps
  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
  // CHECK: store <4 x float> %{{.*}}, <4 x float>* {{.*}}, align 16
  _mm_storer_ps(x, y);
}

void test_mm_storeu_ps(float* x,  __m128 y) {
  // CHECK-LABEL: test_mm_storeu_ps
  // CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 1{{$}}
  // CHECK-NEXT: ret void
  _mm_storeu_ps(x, y);
}

void test_mm_stream_ps(float*A, __m128 B) {
  // CHECK-LABEL: test_mm_stream_ps
  // CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 16, !nontemporal
  _mm_stream_ps(A, B);
}

__m128 test_mm_sub_ps(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_sub_ps
  // CHECK: fsub <4 x float>
  return _mm_sub_ps(A, B);
}

__m128 test_mm_sub_ss(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_sub_ss
  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
  // CHECK: fsub float
  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 0
  return _mm_sub_ss(A, B);
}

void test_MM_TRANSPOSE4_PS(__m128 *A, __m128 *B, __m128 *C, __m128 *D) {
  // CHECK-LABEL: test_MM_TRANSPOSE4_PS
  // CHECK: shufflevector <4 x float> {{.*}}, <4 x float> {{.*}}, <4 x i32> <i32 0, i32 4, i32 1, i32 5>
  // CHECK: shufflevector <4 x float> {{.*}}, <4 x float> {{.*}}, <4 x i32> <i32 0, i32 4, i32 1, i32 5>
  // CHECK: shufflevector <4 x float> {{.*}}, <4 x float> {{.*}}, <4 x i32> <i32 2, i32 6, i32 3, i32 7>
  // CHECK: shufflevector <4 x float> {{.*}}, <4 x float> {{.*}}, <4 x i32> <i32 2, i32 6, i32 3, i32 7>
  // CHECK: shufflevector <4 x float> {{.*}}, <4 x float> {{.*}}, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
  // CHECK: shufflevector <4 x float> {{.*}}, <4 x float> {{.*}}, <4 x i32> <i32 6, i32 7, i32 2, i32 3>
  // CHECK: shufflevector <4 x float> {{.*}}, <4 x float> {{.*}}, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
  // CHECK: shufflevector <4 x float> {{.*}}, <4 x float> {{.*}}, <4 x i32> <i32 6, i32 7, i32 2, i32 3>
  _MM_TRANSPOSE4_PS(*A, *B, *C, *D);
}

int test_mm_ucomieq_ss(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_ucomieq_ss
  // CHECK: call i32 @llvm.x86.sse.ucomieq.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}})
  return _mm_ucomieq_ss(A, B);
}

int test_mm_ucomige_ss(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_ucomige_ss
  // CHECK: call i32 @llvm.x86.sse.ucomige.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}})
  return _mm_ucomige_ss(A, B);
}

int test_mm_ucomigt_ss(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_ucomigt_ss
  // CHECK: call i32 @llvm.x86.sse.ucomigt.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}})
  return _mm_ucomigt_ss(A, B);
}

int test_mm_ucomile_ss(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_ucomile_ss
  // CHECK: call i32 @llvm.x86.sse.ucomile.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}})
  return _mm_ucomile_ss(A, B);
}

int test_mm_ucomilt_ss(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_ucomilt_ss
  // CHECK: call i32 @llvm.x86.sse.ucomilt.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}})
  return _mm_ucomilt_ss(A, B);
}

int test_mm_ucomineq_ss(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_ucomineq_ss
  // CHECK: call i32 @llvm.x86.sse.ucomineq.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}})
  return _mm_ucomineq_ss(A, B);
}

__m128 test_mm_undefined_ps() {
  // CHECK-LABEL: @test_mm_undefined_ps
  // CHECK: ret <4 x float> zeroinitializer
  return _mm_undefined_ps();
}

__m128 test_mm_unpackhi_ps(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_unpackhi_ps
  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> <i32 2, i32 6, i32 3, i32 7>
  return _mm_unpackhi_ps(A, B);
}

__m128 test_mm_unpacklo_ps(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_unpacklo_ps
  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> <i32 0, i32 4, i32 1, i32 5>
  return _mm_unpacklo_ps(A, B);
}

__m128 test_mm_xor_ps(__m128 A, __m128 B) {
  // CHECK-LABEL: test_mm_xor_ps
  // CHECK: xor <4 x i32>
  return _mm_xor_ps(A, B);
}