avx512-regcall-Mask.ll 37.1 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 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=i386-pc-win32       -mattr=+avx512bw  | FileCheck %s --check-prefix=X32
; RUN: llc < %s -mtriple=x86_64-win32        -mattr=+avx512bw  | FileCheck %s --check-prefix=CHECK64 --check-prefix=WIN64
; RUN: llc < %s -mtriple=x86_64-linux-gnu    -mattr=+avx512bw  | FileCheck %s --check-prefix=CHECK64 --check-prefix=LINUXOSX64

; Test regcall when receiving arguments of v64i1 type
define x86_regcallcc i64 @test_argv64i1(<64 x i1> %x0, <64 x i1> %x1, <64 x i1> %x2, <64 x i1> %x3, <64 x i1> %x4, <64 x i1> %x5, <64 x i1> %x6, <64 x i1> %x7, <64 x i1> %x8, <64 x i1> %x9, <64 x i1> %x10, <64 x i1> %x11, <64 x i1> %x12)  {
; X32-LABEL: test_argv64i1:
; X32:       # %bb.0:
; X32-NEXT:    addl %edx, %eax
; X32-NEXT:    adcl %edi, %ecx
; X32-NEXT:    addl {{[0-9]+}}(%esp), %eax
; X32-NEXT:    adcl {{[0-9]+}}(%esp), %ecx
; X32-NEXT:    addl {{[0-9]+}}(%esp), %eax
; X32-NEXT:    adcl {{[0-9]+}}(%esp), %ecx
; X32-NEXT:    addl {{[0-9]+}}(%esp), %eax
; X32-NEXT:    adcl {{[0-9]+}}(%esp), %ecx
; X32-NEXT:    addl {{[0-9]+}}(%esp), %eax
; X32-NEXT:    adcl {{[0-9]+}}(%esp), %ecx
; X32-NEXT:    addl {{[0-9]+}}(%esp), %eax
; X32-NEXT:    adcl {{[0-9]+}}(%esp), %ecx
; X32-NEXT:    addl {{[0-9]+}}(%esp), %eax
; X32-NEXT:    adcl {{[0-9]+}}(%esp), %ecx
; X32-NEXT:    addl {{[0-9]+}}(%esp), %eax
; X32-NEXT:    adcl {{[0-9]+}}(%esp), %ecx
; X32-NEXT:    addl {{[0-9]+}}(%esp), %eax
; X32-NEXT:    adcl {{[0-9]+}}(%esp), %ecx
; X32-NEXT:    addl {{[0-9]+}}(%esp), %eax
; X32-NEXT:    adcl {{[0-9]+}}(%esp), %ecx
; X32-NEXT:    addl {{[0-9]+}}(%esp), %eax
; X32-NEXT:    adcl {{[0-9]+}}(%esp), %ecx
; X32-NEXT:    addl {{[0-9]+}}(%esp), %eax
; X32-NEXT:    adcl {{[0-9]+}}(%esp), %ecx
; X32-NEXT:    retl
;
; WIN64-LABEL: test_argv64i1:
; WIN64:       # %bb.0:
; WIN64-NEXT:    addq %rcx, %rax
; WIN64-NEXT:    addq %rdx, %rax
; WIN64-NEXT:    addq %rdi, %rax
; WIN64-NEXT:    addq %rsi, %rax
; WIN64-NEXT:    addq %r8, %rax
; WIN64-NEXT:    addq %r9, %rax
; WIN64-NEXT:    addq %r10, %rax
; WIN64-NEXT:    addq %r11, %rax
; WIN64-NEXT:    addq %r12, %rax
; WIN64-NEXT:    addq %r14, %rax
; WIN64-NEXT:    addq %r15, %rax
; WIN64-NEXT:    addq {{[0-9]+}}(%rsp), %rax
; WIN64-NEXT:    retq
;
; LINUXOSX64-LABEL: test_argv64i1:
; LINUXOSX64:       # %bb.0:
; LINUXOSX64-NEXT:    addq %rcx, %rax
; LINUXOSX64-NEXT:    addq %rdx, %rax
; LINUXOSX64-NEXT:    addq %rdi, %rax
; LINUXOSX64-NEXT:    addq %rsi, %rax
; LINUXOSX64-NEXT:    addq %r8, %rax
; LINUXOSX64-NEXT:    addq %r9, %rax
; LINUXOSX64-NEXT:    addq %r12, %rax
; LINUXOSX64-NEXT:    addq %r13, %rax
; LINUXOSX64-NEXT:    addq %r14, %rax
; LINUXOSX64-NEXT:    addq %r15, %rax
; LINUXOSX64-NEXT:    addq {{[0-9]+}}(%rsp), %rax
; LINUXOSX64-NEXT:    addq {{[0-9]+}}(%rsp), %rax
; LINUXOSX64-NEXT:    retq
  %y0 = bitcast <64 x i1> %x0 to i64
  %y1 = bitcast <64 x i1> %x1 to i64
  %y2 = bitcast <64 x i1> %x2 to i64
  %y3 = bitcast <64 x i1> %x3 to i64
  %y4 = bitcast <64 x i1> %x4 to i64
  %y5 = bitcast <64 x i1> %x5 to i64
  %y6 = bitcast <64 x i1> %x6 to i64
  %y7 = bitcast <64 x i1> %x7 to i64
  %y8 = bitcast <64 x i1> %x8 to i64
  %y9 = bitcast <64 x i1> %x9 to i64
  %y10 = bitcast <64 x i1> %x10 to i64
  %y11 = bitcast <64 x i1> %x11 to i64
  %y12 = bitcast <64 x i1> %x12 to i64
  %add1 = add i64 %y0, %y1
  %add2 = add i64 %add1, %y2
  %add3 = add i64 %add2, %y3
  %add4 = add i64 %add3, %y4
  %add5 = add i64 %add4, %y5
  %add6 = add i64 %add5, %y6
  %add7 = add i64 %add6, %y7
  %add8 = add i64 %add7, %y8
  %add9 = add i64 %add8, %y9
  %add10 = add i64 %add9, %y10
  %add11 = add i64 %add10, %y11
  %add12 = add i64 %add11, %y12
  ret i64 %add12
}

; Test regcall when passing arguments of v64i1 type
define i64 @caller_argv64i1() #0 {
; X32-LABEL: caller_argv64i1:
; X32:       # %bb.0: # %entry
; X32-NEXT:    pushl %edi
; X32-NEXT:    subl $88, %esp
; X32-NEXT:    vmovaps {{.*#+}} xmm0 = [2,1,2,1]
; X32-NEXT:    vmovups %xmm0, {{[0-9]+}}(%esp)
; X32-NEXT:    vmovaps {{.*#+}} zmm0 = [2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1]
; X32-NEXT:    vmovups %zmm0, (%esp)
; X32-NEXT:    movl $1, {{[0-9]+}}(%esp)
; X32-NEXT:    movl $2, {{[0-9]+}}(%esp)
; X32-NEXT:    movl $2, %eax
; X32-NEXT:    movl $1, %ecx
; X32-NEXT:    movl $2, %edx
; X32-NEXT:    movl $1, %edi
; X32-NEXT:    vzeroupper
; X32-NEXT:    calll _test_argv64i1
; X32-NEXT:    movl %ecx, %edx
; X32-NEXT:    addl $88, %esp
; X32-NEXT:    popl %edi
; X32-NEXT:    retl
;
; WIN64-LABEL: caller_argv64i1:
; WIN64:       # %bb.0: # %entry
; WIN64-NEXT:    pushq %r15
; WIN64-NEXT:    .seh_pushreg %r15
; WIN64-NEXT:    pushq %r14
; WIN64-NEXT:    .seh_pushreg %r14
; WIN64-NEXT:    pushq %r12
; WIN64-NEXT:    .seh_pushreg %r12
; WIN64-NEXT:    pushq %rsi
; WIN64-NEXT:    .seh_pushreg %rsi
; WIN64-NEXT:    pushq %rdi
; WIN64-NEXT:    .seh_pushreg %rdi
; WIN64-NEXT:    subq $48, %rsp
; WIN64-NEXT:    .seh_stackalloc 48
; WIN64-NEXT:    vmovaps %xmm7, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; WIN64-NEXT:    .seh_savexmm %xmm7, 32
; WIN64-NEXT:    vmovaps %xmm6, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; WIN64-NEXT:    .seh_savexmm %xmm6, 16
; WIN64-NEXT:    .seh_endprologue
; WIN64-NEXT:    movabsq $4294967298, %rax # imm = 0x100000002
; WIN64-NEXT:    movq %rax, (%rsp)
; WIN64-NEXT:    movq %rax, %rcx
; WIN64-NEXT:    movq %rax, %rdx
; WIN64-NEXT:    movq %rax, %rdi
; WIN64-NEXT:    movq %rax, %r8
; WIN64-NEXT:    movq %rax, %r9
; WIN64-NEXT:    movq %rax, %r10
; WIN64-NEXT:    movq %rax, %r11
; WIN64-NEXT:    movq %rax, %r12
; WIN64-NEXT:    movq %rax, %r14
; WIN64-NEXT:    movq %rax, %r15
; WIN64-NEXT:    movq %rax, %rsi
; WIN64-NEXT:    callq test_argv64i1
; WIN64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm6 # 16-byte Reload
; WIN64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm7 # 16-byte Reload
; WIN64-NEXT:    addq $48, %rsp
; WIN64-NEXT:    popq %rdi
; WIN64-NEXT:    popq %rsi
; WIN64-NEXT:    popq %r12
; WIN64-NEXT:    popq %r14
; WIN64-NEXT:    popq %r15
; WIN64-NEXT:    retq
; WIN64-NEXT:    .seh_handlerdata
; WIN64-NEXT:    .text
; WIN64-NEXT:    .seh_endproc
;
; LINUXOSX64-LABEL: caller_argv64i1:
; LINUXOSX64:       # %bb.0: # %entry
; LINUXOSX64-NEXT:    pushq %r15
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 16
; LINUXOSX64-NEXT:    pushq %r14
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 24
; LINUXOSX64-NEXT:    pushq %r13
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 32
; LINUXOSX64-NEXT:    pushq %r12
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 40
; LINUXOSX64-NEXT:    pushq %rax
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 48
; LINUXOSX64-NEXT:    .cfi_offset %r12, -40
; LINUXOSX64-NEXT:    .cfi_offset %r13, -32
; LINUXOSX64-NEXT:    .cfi_offset %r14, -24
; LINUXOSX64-NEXT:    .cfi_offset %r15, -16
; LINUXOSX64-NEXT:    movabsq $4294967298, %rax # imm = 0x100000002
; LINUXOSX64-NEXT:    movq %rax, %rcx
; LINUXOSX64-NEXT:    movq %rax, %rdx
; LINUXOSX64-NEXT:    movq %rax, %rdi
; LINUXOSX64-NEXT:    movq %rax, %r8
; LINUXOSX64-NEXT:    movq %rax, %r9
; LINUXOSX64-NEXT:    movq %rax, %r12
; LINUXOSX64-NEXT:    movq %rax, %r13
; LINUXOSX64-NEXT:    movq %rax, %r14
; LINUXOSX64-NEXT:    movq %rax, %r15
; LINUXOSX64-NEXT:    movq %rax, %rsi
; LINUXOSX64-NEXT:    pushq %rax
; LINUXOSX64-NEXT:    .cfi_adjust_cfa_offset 8
; LINUXOSX64-NEXT:    pushq %rax
; LINUXOSX64-NEXT:    .cfi_adjust_cfa_offset 8
; LINUXOSX64-NEXT:    callq test_argv64i1
; LINUXOSX64-NEXT:    addq $24, %rsp
; LINUXOSX64-NEXT:    .cfi_adjust_cfa_offset -24
; LINUXOSX64-NEXT:    popq %r12
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 32
; LINUXOSX64-NEXT:    popq %r13
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 24
; LINUXOSX64-NEXT:    popq %r14
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 16
; LINUXOSX64-NEXT:    popq %r15
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 8
; LINUXOSX64-NEXT:    retq
entry:
  %v0 = bitcast i64 4294967298 to <64 x i1>
  %call = call x86_regcallcc i64 @test_argv64i1(<64 x i1> %v0, <64 x i1> %v0, <64 x i1> %v0,
                                                <64 x i1> %v0, <64 x i1> %v0, <64 x i1> %v0,
                                                <64 x i1> %v0, <64 x i1> %v0, <64 x i1> %v0,
                                                <64 x i1> %v0, <64 x i1> %v0, <64 x i1> %v0,
                                                <64 x i1> %v0)
  ret i64 %call
}

; Test regcall when returning v64i1 type
define x86_regcallcc <64 x i1> @test_retv64i1()  {
; X32-LABEL: test_retv64i1:
; X32:       # %bb.0:
; X32-NEXT:    movl $2, %eax
; X32-NEXT:    movl $1, %ecx
; X32-NEXT:    retl
;
; CHECK64-LABEL: test_retv64i1:
; CHECK64:       # %bb.0:
; CHECK64-NEXT:    movabsq $4294967298, %rax # imm = 0x100000002
; CHECK64-NEXT:    retq
  %a = bitcast i64 4294967298 to <64 x i1>
 ret <64 x i1> %a
}

; Test regcall when processing result of v64i1 type
define <64 x i1> @caller_retv64i1() #0 {
; X32-LABEL: caller_retv64i1:
; X32:       # %bb.0: # %entry
; X32-NEXT:    calll _test_retv64i1
; X32-NEXT:    kmovd %eax, %k0
; X32-NEXT:    kmovd %ecx, %k1
; X32-NEXT:    kunpckdq %k0, %k1, %k0
; X32-NEXT:    vpmovm2b %k0, %zmm0
; X32-NEXT:    retl
;
; WIN64-LABEL: caller_retv64i1:
; WIN64:       # %bb.0: # %entry
; WIN64-NEXT:    pushq %rsi
; WIN64-NEXT:    .seh_pushreg %rsi
; WIN64-NEXT:    pushq %rdi
; WIN64-NEXT:    .seh_pushreg %rdi
; WIN64-NEXT:    subq $40, %rsp
; WIN64-NEXT:    .seh_stackalloc 40
; WIN64-NEXT:    vmovaps %xmm7, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; WIN64-NEXT:    .seh_savexmm %xmm7, 16
; WIN64-NEXT:    vmovaps %xmm6, (%rsp) # 16-byte Spill
; WIN64-NEXT:    .seh_savexmm %xmm6, 0
; WIN64-NEXT:    .seh_endprologue
; WIN64-NEXT:    callq test_retv64i1
; WIN64-NEXT:    kmovq %rax, %k0
; WIN64-NEXT:    vpmovm2b %k0, %zmm0
; WIN64-NEXT:    vmovaps (%rsp), %xmm6 # 16-byte Reload
; WIN64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm7 # 16-byte Reload
; WIN64-NEXT:    addq $40, %rsp
; WIN64-NEXT:    popq %rdi
; WIN64-NEXT:    popq %rsi
; WIN64-NEXT:    retq
; WIN64-NEXT:    .seh_handlerdata
; WIN64-NEXT:    .text
; WIN64-NEXT:    .seh_endproc
;
; LINUXOSX64-LABEL: caller_retv64i1:
; LINUXOSX64:       # %bb.0: # %entry
; LINUXOSX64-NEXT:    pushq %rax
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 16
; LINUXOSX64-NEXT:    callq test_retv64i1
; LINUXOSX64-NEXT:    kmovq %rax, %k0
; LINUXOSX64-NEXT:    vpmovm2b %k0, %zmm0
; LINUXOSX64-NEXT:    popq %rax
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 8
; LINUXOSX64-NEXT:    retq
entry:
  %call = call x86_regcallcc <64 x i1> @test_retv64i1()
  ret <64 x i1> %call
}

; Test regcall when receiving arguments of v32i1 type
declare i32 @test_argv32i1helper(<32 x i1> %x0, <32 x i1> %x1, <32 x i1> %x2)
define x86_regcallcc i32 @test_argv32i1(<32 x i1> %x0, <32 x i1> %x1, <32 x i1> %x2)  {
; X32-LABEL: test_argv32i1:
; X32:       # %bb.0: # %entry
; X32-NEXT:    pushl %esp
; X32-NEXT:    subl $72, %esp
; X32-NEXT:    vmovups %xmm7, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
; X32-NEXT:    vmovups %xmm6, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
; X32-NEXT:    vmovups %xmm5, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
; X32-NEXT:    vmovups %xmm4, (%esp) # 16-byte Spill
; X32-NEXT:    kmovd %edx, %k0
; X32-NEXT:    kmovd %ecx, %k1
; X32-NEXT:    kmovd %eax, %k2
; X32-NEXT:    vpmovm2b %k2, %zmm0
; X32-NEXT:    vpmovm2b %k1, %zmm1
; X32-NEXT:    vpmovm2b %k0, %zmm2
; X32-NEXT:    # kill: def $ymm0 killed $ymm0 killed $zmm0
; X32-NEXT:    # kill: def $ymm1 killed $ymm1 killed $zmm1
; X32-NEXT:    # kill: def $ymm2 killed $ymm2 killed $zmm2
; X32-NEXT:    calll _test_argv32i1helper
; X32-NEXT:    vmovups (%esp), %xmm4 # 16-byte Reload
; X32-NEXT:    vmovups {{[-0-9]+}}(%e{{[sb]}}p), %xmm5 # 16-byte Reload
; X32-NEXT:    vmovups {{[-0-9]+}}(%e{{[sb]}}p), %xmm6 # 16-byte Reload
; X32-NEXT:    vmovups {{[-0-9]+}}(%e{{[sb]}}p), %xmm7 # 16-byte Reload
; X32-NEXT:    addl $72, %esp
; X32-NEXT:    popl %esp
; X32-NEXT:    vzeroupper
; X32-NEXT:    retl
;
; WIN64-LABEL: test_argv32i1:
; WIN64:       # %bb.0: # %entry
; WIN64-NEXT:    pushq %r11
; WIN64-NEXT:    .seh_pushreg %r11
; WIN64-NEXT:    pushq %r10
; WIN64-NEXT:    .seh_pushreg %r10
; WIN64-NEXT:    pushq %rsp
; WIN64-NEXT:    .seh_pushreg %rsp
; WIN64-NEXT:    subq $32, %rsp
; WIN64-NEXT:    .seh_stackalloc 32
; WIN64-NEXT:    .seh_endprologue
; WIN64-NEXT:    kmovd %edx, %k0
; WIN64-NEXT:    kmovd %ecx, %k1
; WIN64-NEXT:    kmovd %eax, %k2
; WIN64-NEXT:    vpmovm2b %k2, %zmm0
; WIN64-NEXT:    vpmovm2b %k1, %zmm1
; WIN64-NEXT:    vpmovm2b %k0, %zmm2
; WIN64-NEXT:    # kill: def $ymm0 killed $ymm0 killed $zmm0
; WIN64-NEXT:    # kill: def $ymm1 killed $ymm1 killed $zmm1
; WIN64-NEXT:    # kill: def $ymm2 killed $ymm2 killed $zmm2
; WIN64-NEXT:    callq test_argv32i1helper
; WIN64-NEXT:    nop
; WIN64-NEXT:    addq $32, %rsp
; WIN64-NEXT:    popq %rsp
; WIN64-NEXT:    popq %r10
; WIN64-NEXT:    popq %r11
; WIN64-NEXT:    vzeroupper
; WIN64-NEXT:    retq
; WIN64-NEXT:    .seh_handlerdata
; WIN64-NEXT:    .text
; WIN64-NEXT:    .seh_endproc
;
; LINUXOSX64-LABEL: test_argv32i1:
; LINUXOSX64:       # %bb.0: # %entry
; LINUXOSX64-NEXT:    pushq %rsp
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 16
; LINUXOSX64-NEXT:    subq $128, %rsp
; LINUXOSX64-NEXT:    vmovaps %xmm15, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm14, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm13, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm12, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm11, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm10, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm9, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm8, (%rsp) # 16-byte Spill
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 144
; LINUXOSX64-NEXT:    .cfi_offset %rsp, -16
; LINUXOSX64-NEXT:    .cfi_offset %xmm8, -144
; LINUXOSX64-NEXT:    .cfi_offset %xmm9, -128
; LINUXOSX64-NEXT:    .cfi_offset %xmm10, -112
; LINUXOSX64-NEXT:    .cfi_offset %xmm11, -96
; LINUXOSX64-NEXT:    .cfi_offset %xmm12, -80
; LINUXOSX64-NEXT:    .cfi_offset %xmm13, -64
; LINUXOSX64-NEXT:    .cfi_offset %xmm14, -48
; LINUXOSX64-NEXT:    .cfi_offset %xmm15, -32
; LINUXOSX64-NEXT:    kmovd %edx, %k0
; LINUXOSX64-NEXT:    kmovd %ecx, %k1
; LINUXOSX64-NEXT:    kmovd %eax, %k2
; LINUXOSX64-NEXT:    vpmovm2b %k2, %zmm0
; LINUXOSX64-NEXT:    vpmovm2b %k1, %zmm1
; LINUXOSX64-NEXT:    vpmovm2b %k0, %zmm2
; LINUXOSX64-NEXT:    # kill: def $ymm0 killed $ymm0 killed $zmm0
; LINUXOSX64-NEXT:    # kill: def $ymm1 killed $ymm1 killed $zmm1
; LINUXOSX64-NEXT:    # kill: def $ymm2 killed $ymm2 killed $zmm2
; LINUXOSX64-NEXT:    callq test_argv32i1helper
; LINUXOSX64-NEXT:    vmovaps (%rsp), %xmm8 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm9 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm10 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm11 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm12 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm13 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm14 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm15 # 16-byte Reload
; LINUXOSX64-NEXT:    addq $128, %rsp
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 16
; LINUXOSX64-NEXT:    popq %rsp
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 8
; LINUXOSX64-NEXT:    vzeroupper
; LINUXOSX64-NEXT:    retq
entry:
  %res = call i32 @test_argv32i1helper(<32 x i1> %x0, <32 x i1> %x1, <32 x i1> %x2)
  ret i32 %res
}

; Test regcall when passing arguments of v32i1 type
define i32 @caller_argv32i1() #0 {
; X32-LABEL: caller_argv32i1:
; X32:       # %bb.0: # %entry
; X32-NEXT:    movl $1, %eax
; X32-NEXT:    movl $1, %ecx
; X32-NEXT:    movl $1, %edx
; X32-NEXT:    calll _test_argv32i1
; X32-NEXT:    retl
;
; WIN64-LABEL: caller_argv32i1:
; WIN64:       # %bb.0: # %entry
; WIN64-NEXT:    pushq %rsi
; WIN64-NEXT:    .seh_pushreg %rsi
; WIN64-NEXT:    pushq %rdi
; WIN64-NEXT:    .seh_pushreg %rdi
; WIN64-NEXT:    subq $40, %rsp
; WIN64-NEXT:    .seh_stackalloc 40
; WIN64-NEXT:    vmovaps %xmm7, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; WIN64-NEXT:    .seh_savexmm %xmm7, 16
; WIN64-NEXT:    vmovaps %xmm6, (%rsp) # 16-byte Spill
; WIN64-NEXT:    .seh_savexmm %xmm6, 0
; WIN64-NEXT:    .seh_endprologue
; WIN64-NEXT:    movl $1, %eax
; WIN64-NEXT:    movl $1, %ecx
; WIN64-NEXT:    movl $1, %edx
; WIN64-NEXT:    callq test_argv32i1
; WIN64-NEXT:    vmovaps (%rsp), %xmm6 # 16-byte Reload
; WIN64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm7 # 16-byte Reload
; WIN64-NEXT:    addq $40, %rsp
; WIN64-NEXT:    popq %rdi
; WIN64-NEXT:    popq %rsi
; WIN64-NEXT:    retq
; WIN64-NEXT:    .seh_handlerdata
; WIN64-NEXT:    .text
; WIN64-NEXT:    .seh_endproc
;
; LINUXOSX64-LABEL: caller_argv32i1:
; LINUXOSX64:       # %bb.0: # %entry
; LINUXOSX64-NEXT:    pushq %rax
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 16
; LINUXOSX64-NEXT:    movl $1, %eax
; LINUXOSX64-NEXT:    movl $1, %ecx
; LINUXOSX64-NEXT:    movl $1, %edx
; LINUXOSX64-NEXT:    callq test_argv32i1
; LINUXOSX64-NEXT:    popq %rcx
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 8
; LINUXOSX64-NEXT:    retq
entry:
  %v0 = bitcast i32 1 to <32 x i1>
  %call = call x86_regcallcc i32 @test_argv32i1(<32 x i1> %v0, <32 x i1> %v0, <32 x i1> %v0)
  ret i32 %call
}

; Test regcall when returning v32i1 type
define x86_regcallcc <32 x i1> @test_retv32i1()  {
; X32-LABEL: test_retv32i1:
; X32:       # %bb.0:
; X32-NEXT:    movl $1, %eax
; X32-NEXT:    retl
;
; CHECK64-LABEL: test_retv32i1:
; CHECK64:       # %bb.0:
; CHECK64-NEXT:    movl $1, %eax
; CHECK64-NEXT:    retq
  %a = bitcast i32 1 to <32 x i1>
  ret <32 x i1> %a
}

; Test regcall when processing result of v32i1 type
define i32 @caller_retv32i1() #0 {
; X32-LABEL: caller_retv32i1:
; X32:       # %bb.0: # %entry
; X32-NEXT:    calll _test_retv32i1
; X32-NEXT:    incl %eax
; X32-NEXT:    retl
;
; WIN64-LABEL: caller_retv32i1:
; WIN64:       # %bb.0: # %entry
; WIN64-NEXT:    pushq %rsi
; WIN64-NEXT:    .seh_pushreg %rsi
; WIN64-NEXT:    pushq %rdi
; WIN64-NEXT:    .seh_pushreg %rdi
; WIN64-NEXT:    subq $40, %rsp
; WIN64-NEXT:    .seh_stackalloc 40
; WIN64-NEXT:    vmovaps %xmm7, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; WIN64-NEXT:    .seh_savexmm %xmm7, 16
; WIN64-NEXT:    vmovaps %xmm6, (%rsp) # 16-byte Spill
; WIN64-NEXT:    .seh_savexmm %xmm6, 0
; WIN64-NEXT:    .seh_endprologue
; WIN64-NEXT:    callq test_retv32i1
; WIN64-NEXT:    incl %eax
; WIN64-NEXT:    vmovaps (%rsp), %xmm6 # 16-byte Reload
; WIN64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm7 # 16-byte Reload
; WIN64-NEXT:    addq $40, %rsp
; WIN64-NEXT:    popq %rdi
; WIN64-NEXT:    popq %rsi
; WIN64-NEXT:    retq
; WIN64-NEXT:    .seh_handlerdata
; WIN64-NEXT:    .text
; WIN64-NEXT:    .seh_endproc
;
; LINUXOSX64-LABEL: caller_retv32i1:
; LINUXOSX64:       # %bb.0: # %entry
; LINUXOSX64-NEXT:    pushq %rax
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 16
; LINUXOSX64-NEXT:    callq test_retv32i1
; LINUXOSX64-NEXT:    incl %eax
; LINUXOSX64-NEXT:    popq %rcx
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 8
; LINUXOSX64-NEXT:    retq
entry:
  %call = call x86_regcallcc <32 x i1> @test_retv32i1()
  %c = bitcast <32 x i1> %call to i32
  %add = add i32 %c, 1
  ret i32 %add
}

; Test regcall when receiving arguments of v16i1 type
declare i16 @test_argv16i1helper(<16 x i1> %x0, <16 x i1> %x1, <16 x i1> %x2)
define x86_regcallcc i16 @test_argv16i1(<16 x i1> %x0, <16 x i1> %x1, <16 x i1> %x2)  {
; X32-LABEL: test_argv16i1:
; X32:       # %bb.0:
; X32-NEXT:    pushl %esp
; X32-NEXT:    subl $72, %esp
; X32-NEXT:    vmovups %xmm7, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
; X32-NEXT:    vmovups %xmm6, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
; X32-NEXT:    vmovups %xmm5, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
; X32-NEXT:    vmovups %xmm4, (%esp) # 16-byte Spill
; X32-NEXT:    kmovd %edx, %k0
; X32-NEXT:    kmovd %ecx, %k1
; X32-NEXT:    kmovd %eax, %k2
; X32-NEXT:    vpmovm2b %k2, %zmm0
; X32-NEXT:    vpmovm2b %k1, %zmm1
; X32-NEXT:    vpmovm2b %k0, %zmm2
; X32-NEXT:    # kill: def $xmm0 killed $xmm0 killed $zmm0
; X32-NEXT:    # kill: def $xmm1 killed $xmm1 killed $zmm1
; X32-NEXT:    # kill: def $xmm2 killed $xmm2 killed $zmm2
; X32-NEXT:    vzeroupper
; X32-NEXT:    calll _test_argv16i1helper
; X32-NEXT:    vmovups (%esp), %xmm4 # 16-byte Reload
; X32-NEXT:    vmovups {{[-0-9]+}}(%e{{[sb]}}p), %xmm5 # 16-byte Reload
; X32-NEXT:    vmovups {{[-0-9]+}}(%e{{[sb]}}p), %xmm6 # 16-byte Reload
; X32-NEXT:    vmovups {{[-0-9]+}}(%e{{[sb]}}p), %xmm7 # 16-byte Reload
; X32-NEXT:    addl $72, %esp
; X32-NEXT:    popl %esp
; X32-NEXT:    retl
;
; WIN64-LABEL: test_argv16i1:
; WIN64:       # %bb.0:
; WIN64-NEXT:    pushq %r11
; WIN64-NEXT:    .seh_pushreg %r11
; WIN64-NEXT:    pushq %r10
; WIN64-NEXT:    .seh_pushreg %r10
; WIN64-NEXT:    pushq %rsp
; WIN64-NEXT:    .seh_pushreg %rsp
; WIN64-NEXT:    subq $32, %rsp
; WIN64-NEXT:    .seh_stackalloc 32
; WIN64-NEXT:    .seh_endprologue
; WIN64-NEXT:    kmovd %edx, %k0
; WIN64-NEXT:    kmovd %ecx, %k1
; WIN64-NEXT:    kmovd %eax, %k2
; WIN64-NEXT:    vpmovm2b %k2, %zmm0
; WIN64-NEXT:    vpmovm2b %k1, %zmm1
; WIN64-NEXT:    vpmovm2b %k0, %zmm2
; WIN64-NEXT:    # kill: def $xmm0 killed $xmm0 killed $zmm0
; WIN64-NEXT:    # kill: def $xmm1 killed $xmm1 killed $zmm1
; WIN64-NEXT:    # kill: def $xmm2 killed $xmm2 killed $zmm2
; WIN64-NEXT:    vzeroupper
; WIN64-NEXT:    callq test_argv16i1helper
; WIN64-NEXT:    nop
; WIN64-NEXT:    addq $32, %rsp
; WIN64-NEXT:    popq %rsp
; WIN64-NEXT:    popq %r10
; WIN64-NEXT:    popq %r11
; WIN64-NEXT:    retq
; WIN64-NEXT:    .seh_handlerdata
; WIN64-NEXT:    .text
; WIN64-NEXT:    .seh_endproc
;
; LINUXOSX64-LABEL: test_argv16i1:
; LINUXOSX64:       # %bb.0:
; LINUXOSX64-NEXT:    pushq %rsp
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 16
; LINUXOSX64-NEXT:    subq $128, %rsp
; LINUXOSX64-NEXT:    vmovaps %xmm15, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm14, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm13, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm12, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm11, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm10, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm9, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm8, (%rsp) # 16-byte Spill
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 144
; LINUXOSX64-NEXT:    .cfi_offset %rsp, -16
; LINUXOSX64-NEXT:    .cfi_offset %xmm8, -144
; LINUXOSX64-NEXT:    .cfi_offset %xmm9, -128
; LINUXOSX64-NEXT:    .cfi_offset %xmm10, -112
; LINUXOSX64-NEXT:    .cfi_offset %xmm11, -96
; LINUXOSX64-NEXT:    .cfi_offset %xmm12, -80
; LINUXOSX64-NEXT:    .cfi_offset %xmm13, -64
; LINUXOSX64-NEXT:    .cfi_offset %xmm14, -48
; LINUXOSX64-NEXT:    .cfi_offset %xmm15, -32
; LINUXOSX64-NEXT:    kmovd %edx, %k0
; LINUXOSX64-NEXT:    kmovd %ecx, %k1
; LINUXOSX64-NEXT:    kmovd %eax, %k2
; LINUXOSX64-NEXT:    vpmovm2b %k2, %zmm0
; LINUXOSX64-NEXT:    vpmovm2b %k1, %zmm1
; LINUXOSX64-NEXT:    vpmovm2b %k0, %zmm2
; LINUXOSX64-NEXT:    # kill: def $xmm0 killed $xmm0 killed $zmm0
; LINUXOSX64-NEXT:    # kill: def $xmm1 killed $xmm1 killed $zmm1
; LINUXOSX64-NEXT:    # kill: def $xmm2 killed $xmm2 killed $zmm2
; LINUXOSX64-NEXT:    vzeroupper
; LINUXOSX64-NEXT:    callq test_argv16i1helper
; LINUXOSX64-NEXT:    vmovaps (%rsp), %xmm8 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm9 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm10 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm11 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm12 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm13 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm14 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm15 # 16-byte Reload
; LINUXOSX64-NEXT:    addq $128, %rsp
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 16
; LINUXOSX64-NEXT:    popq %rsp
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 8
; LINUXOSX64-NEXT:    retq
  %res = call i16 @test_argv16i1helper(<16 x i1> %x0, <16 x i1> %x1, <16 x i1> %x2)
  ret i16 %res
}

; Test regcall when passing arguments of v16i1 type
define i16 @caller_argv16i1() #0 {
; X32-LABEL: caller_argv16i1:
; X32:       # %bb.0: # %entry
; X32-NEXT:    movl $1, %eax
; X32-NEXT:    movl $1, %ecx
; X32-NEXT:    movl $1, %edx
; X32-NEXT:    calll _test_argv16i1
; X32-NEXT:    retl
;
; WIN64-LABEL: caller_argv16i1:
; WIN64:       # %bb.0: # %entry
; WIN64-NEXT:    pushq %rsi
; WIN64-NEXT:    .seh_pushreg %rsi
; WIN64-NEXT:    pushq %rdi
; WIN64-NEXT:    .seh_pushreg %rdi
; WIN64-NEXT:    subq $40, %rsp
; WIN64-NEXT:    .seh_stackalloc 40
; WIN64-NEXT:    vmovaps %xmm7, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; WIN64-NEXT:    .seh_savexmm %xmm7, 16
; WIN64-NEXT:    vmovaps %xmm6, (%rsp) # 16-byte Spill
; WIN64-NEXT:    .seh_savexmm %xmm6, 0
; WIN64-NEXT:    .seh_endprologue
; WIN64-NEXT:    movl $1, %eax
; WIN64-NEXT:    movl $1, %ecx
; WIN64-NEXT:    movl $1, %edx
; WIN64-NEXT:    callq test_argv16i1
; WIN64-NEXT:    vmovaps (%rsp), %xmm6 # 16-byte Reload
; WIN64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm7 # 16-byte Reload
; WIN64-NEXT:    addq $40, %rsp
; WIN64-NEXT:    popq %rdi
; WIN64-NEXT:    popq %rsi
; WIN64-NEXT:    retq
; WIN64-NEXT:    .seh_handlerdata
; WIN64-NEXT:    .text
; WIN64-NEXT:    .seh_endproc
;
; LINUXOSX64-LABEL: caller_argv16i1:
; LINUXOSX64:       # %bb.0: # %entry
; LINUXOSX64-NEXT:    pushq %rax
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 16
; LINUXOSX64-NEXT:    movl $1, %eax
; LINUXOSX64-NEXT:    movl $1, %ecx
; LINUXOSX64-NEXT:    movl $1, %edx
; LINUXOSX64-NEXT:    callq test_argv16i1
; LINUXOSX64-NEXT:    popq %rcx
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 8
; LINUXOSX64-NEXT:    retq
entry:
  %v0 = bitcast i16 1 to <16 x i1>
  %call = call x86_regcallcc i16 @test_argv16i1(<16 x i1> %v0, <16 x i1> %v0, <16 x i1> %v0)
  ret i16 %call
}

; Test regcall when returning v16i1 type
define x86_regcallcc <16 x i1> @test_retv16i1()  {
; X32-LABEL: test_retv16i1:
; X32:       # %bb.0:
; X32-NEXT:    movw $1, %ax
; X32-NEXT:    retl
;
; CHECK64-LABEL: test_retv16i1:
; CHECK64:       # %bb.0:
; CHECK64-NEXT:    movw $1, %ax
; CHECK64-NEXT:    retq
  %a = bitcast i16 1 to <16 x i1>
  ret <16 x i1> %a
}

; Test regcall when processing result of v16i1 type
define i16 @caller_retv16i1() #0 {
; X32-LABEL: caller_retv16i1:
; X32:       # %bb.0: # %entry
; X32-NEXT:    calll _test_retv16i1
; X32-NEXT:    # kill: def $ax killed $ax def $eax
; X32-NEXT:    incl %eax
; X32-NEXT:    # kill: def $ax killed $ax killed $eax
; X32-NEXT:    retl
;
; WIN64-LABEL: caller_retv16i1:
; WIN64:       # %bb.0: # %entry
; WIN64-NEXT:    pushq %rsi
; WIN64-NEXT:    .seh_pushreg %rsi
; WIN64-NEXT:    pushq %rdi
; WIN64-NEXT:    .seh_pushreg %rdi
; WIN64-NEXT:    subq $40, %rsp
; WIN64-NEXT:    .seh_stackalloc 40
; WIN64-NEXT:    vmovaps %xmm7, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; WIN64-NEXT:    .seh_savexmm %xmm7, 16
; WIN64-NEXT:    vmovaps %xmm6, (%rsp) # 16-byte Spill
; WIN64-NEXT:    .seh_savexmm %xmm6, 0
; WIN64-NEXT:    .seh_endprologue
; WIN64-NEXT:    callq test_retv16i1
; WIN64-NEXT:    # kill: def $ax killed $ax def $eax
; WIN64-NEXT:    incl %eax
; WIN64-NEXT:    # kill: def $ax killed $ax killed $eax
; WIN64-NEXT:    vmovaps (%rsp), %xmm6 # 16-byte Reload
; WIN64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm7 # 16-byte Reload
; WIN64-NEXT:    addq $40, %rsp
; WIN64-NEXT:    popq %rdi
; WIN64-NEXT:    popq %rsi
; WIN64-NEXT:    retq
; WIN64-NEXT:    .seh_handlerdata
; WIN64-NEXT:    .text
; WIN64-NEXT:    .seh_endproc
;
; LINUXOSX64-LABEL: caller_retv16i1:
; LINUXOSX64:       # %bb.0: # %entry
; LINUXOSX64-NEXT:    pushq %rax
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 16
; LINUXOSX64-NEXT:    callq test_retv16i1
; LINUXOSX64-NEXT:    # kill: def $ax killed $ax def $eax
; LINUXOSX64-NEXT:    incl %eax
; LINUXOSX64-NEXT:    # kill: def $ax killed $ax killed $eax
; LINUXOSX64-NEXT:    popq %rcx
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 8
; LINUXOSX64-NEXT:    retq
entry:
  %call = call x86_regcallcc <16 x i1> @test_retv16i1()
  %c = bitcast <16 x i1> %call to i16
  %add = add i16 %c, 1
  ret i16 %add
}

; Test regcall when receiving arguments of v8i1 type
declare i8 @test_argv8i1helper(<8 x i1> %x0, <8 x i1> %x1, <8 x i1> %x2)
define x86_regcallcc i8 @test_argv8i1(<8 x i1> %x0, <8 x i1> %x1, <8 x i1> %x2)  {
; X32-LABEL: test_argv8i1:
; X32:       # %bb.0:
; X32-NEXT:    pushl %esp
; X32-NEXT:    subl $72, %esp
; X32-NEXT:    vmovups %xmm7, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
; X32-NEXT:    vmovups %xmm6, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
; X32-NEXT:    vmovups %xmm5, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
; X32-NEXT:    vmovups %xmm4, (%esp) # 16-byte Spill
; X32-NEXT:    kmovd %edx, %k0
; X32-NEXT:    kmovd %ecx, %k1
; X32-NEXT:    kmovd %eax, %k2
; X32-NEXT:    vpmovm2w %k2, %zmm0
; X32-NEXT:    vpmovm2w %k1, %zmm1
; X32-NEXT:    vpmovm2w %k0, %zmm2
; X32-NEXT:    # kill: def $xmm0 killed $xmm0 killed $zmm0
; X32-NEXT:    # kill: def $xmm1 killed $xmm1 killed $zmm1
; X32-NEXT:    # kill: def $xmm2 killed $xmm2 killed $zmm2
; X32-NEXT:    vzeroupper
; X32-NEXT:    calll _test_argv8i1helper
; X32-NEXT:    vmovups (%esp), %xmm4 # 16-byte Reload
; X32-NEXT:    vmovups {{[-0-9]+}}(%e{{[sb]}}p), %xmm5 # 16-byte Reload
; X32-NEXT:    vmovups {{[-0-9]+}}(%e{{[sb]}}p), %xmm6 # 16-byte Reload
; X32-NEXT:    vmovups {{[-0-9]+}}(%e{{[sb]}}p), %xmm7 # 16-byte Reload
; X32-NEXT:    addl $72, %esp
; X32-NEXT:    popl %esp
; X32-NEXT:    retl
;
; WIN64-LABEL: test_argv8i1:
; WIN64:       # %bb.0:
; WIN64-NEXT:    pushq %r11
; WIN64-NEXT:    .seh_pushreg %r11
; WIN64-NEXT:    pushq %r10
; WIN64-NEXT:    .seh_pushreg %r10
; WIN64-NEXT:    pushq %rsp
; WIN64-NEXT:    .seh_pushreg %rsp
; WIN64-NEXT:    subq $32, %rsp
; WIN64-NEXT:    .seh_stackalloc 32
; WIN64-NEXT:    .seh_endprologue
; WIN64-NEXT:    kmovd %edx, %k0
; WIN64-NEXT:    kmovd %ecx, %k1
; WIN64-NEXT:    kmovd %eax, %k2
; WIN64-NEXT:    vpmovm2w %k2, %zmm0
; WIN64-NEXT:    vpmovm2w %k1, %zmm1
; WIN64-NEXT:    vpmovm2w %k0, %zmm2
; WIN64-NEXT:    # kill: def $xmm0 killed $xmm0 killed $zmm0
; WIN64-NEXT:    # kill: def $xmm1 killed $xmm1 killed $zmm1
; WIN64-NEXT:    # kill: def $xmm2 killed $xmm2 killed $zmm2
; WIN64-NEXT:    vzeroupper
; WIN64-NEXT:    callq test_argv8i1helper
; WIN64-NEXT:    nop
; WIN64-NEXT:    addq $32, %rsp
; WIN64-NEXT:    popq %rsp
; WIN64-NEXT:    popq %r10
; WIN64-NEXT:    popq %r11
; WIN64-NEXT:    retq
; WIN64-NEXT:    .seh_handlerdata
; WIN64-NEXT:    .text
; WIN64-NEXT:    .seh_endproc
;
; LINUXOSX64-LABEL: test_argv8i1:
; LINUXOSX64:       # %bb.0:
; LINUXOSX64-NEXT:    pushq %rsp
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 16
; LINUXOSX64-NEXT:    subq $128, %rsp
; LINUXOSX64-NEXT:    vmovaps %xmm15, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm14, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm13, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm12, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm11, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm10, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm9, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; LINUXOSX64-NEXT:    vmovaps %xmm8, (%rsp) # 16-byte Spill
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 144
; LINUXOSX64-NEXT:    .cfi_offset %rsp, -16
; LINUXOSX64-NEXT:    .cfi_offset %xmm8, -144
; LINUXOSX64-NEXT:    .cfi_offset %xmm9, -128
; LINUXOSX64-NEXT:    .cfi_offset %xmm10, -112
; LINUXOSX64-NEXT:    .cfi_offset %xmm11, -96
; LINUXOSX64-NEXT:    .cfi_offset %xmm12, -80
; LINUXOSX64-NEXT:    .cfi_offset %xmm13, -64
; LINUXOSX64-NEXT:    .cfi_offset %xmm14, -48
; LINUXOSX64-NEXT:    .cfi_offset %xmm15, -32
; LINUXOSX64-NEXT:    kmovd %edx, %k0
; LINUXOSX64-NEXT:    kmovd %ecx, %k1
; LINUXOSX64-NEXT:    kmovd %eax, %k2
; LINUXOSX64-NEXT:    vpmovm2w %k2, %zmm0
; LINUXOSX64-NEXT:    vpmovm2w %k1, %zmm1
; LINUXOSX64-NEXT:    vpmovm2w %k0, %zmm2
; LINUXOSX64-NEXT:    # kill: def $xmm0 killed $xmm0 killed $zmm0
; LINUXOSX64-NEXT:    # kill: def $xmm1 killed $xmm1 killed $zmm1
; LINUXOSX64-NEXT:    # kill: def $xmm2 killed $xmm2 killed $zmm2
; LINUXOSX64-NEXT:    vzeroupper
; LINUXOSX64-NEXT:    callq test_argv8i1helper
; LINUXOSX64-NEXT:    vmovaps (%rsp), %xmm8 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm9 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm10 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm11 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm12 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm13 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm14 # 16-byte Reload
; LINUXOSX64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm15 # 16-byte Reload
; LINUXOSX64-NEXT:    addq $128, %rsp
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 16
; LINUXOSX64-NEXT:    popq %rsp
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 8
; LINUXOSX64-NEXT:    retq
  %res = call i8 @test_argv8i1helper(<8 x i1> %x0, <8 x i1> %x1, <8 x i1> %x2)
  ret i8 %res
}

; Test regcall when passing arguments of v8i1 type
define i8 @caller_argv8i1() #0 {
; X32-LABEL: caller_argv8i1:
; X32:       # %bb.0: # %entry
; X32-NEXT:    movl $1, %eax
; X32-NEXT:    movl $1, %ecx
; X32-NEXT:    movl $1, %edx
; X32-NEXT:    calll _test_argv8i1
; X32-NEXT:    retl
;
; WIN64-LABEL: caller_argv8i1:
; WIN64:       # %bb.0: # %entry
; WIN64-NEXT:    pushq %rsi
; WIN64-NEXT:    .seh_pushreg %rsi
; WIN64-NEXT:    pushq %rdi
; WIN64-NEXT:    .seh_pushreg %rdi
; WIN64-NEXT:    subq $40, %rsp
; WIN64-NEXT:    .seh_stackalloc 40
; WIN64-NEXT:    vmovaps %xmm7, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; WIN64-NEXT:    .seh_savexmm %xmm7, 16
; WIN64-NEXT:    vmovaps %xmm6, (%rsp) # 16-byte Spill
; WIN64-NEXT:    .seh_savexmm %xmm6, 0
; WIN64-NEXT:    .seh_endprologue
; WIN64-NEXT:    movl $1, %eax
; WIN64-NEXT:    movl $1, %ecx
; WIN64-NEXT:    movl $1, %edx
; WIN64-NEXT:    callq test_argv8i1
; WIN64-NEXT:    vmovaps (%rsp), %xmm6 # 16-byte Reload
; WIN64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm7 # 16-byte Reload
; WIN64-NEXT:    addq $40, %rsp
; WIN64-NEXT:    popq %rdi
; WIN64-NEXT:    popq %rsi
; WIN64-NEXT:    retq
; WIN64-NEXT:    .seh_handlerdata
; WIN64-NEXT:    .text
; WIN64-NEXT:    .seh_endproc
;
; LINUXOSX64-LABEL: caller_argv8i1:
; LINUXOSX64:       # %bb.0: # %entry
; LINUXOSX64-NEXT:    pushq %rax
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 16
; LINUXOSX64-NEXT:    movl $1, %eax
; LINUXOSX64-NEXT:    movl $1, %ecx
; LINUXOSX64-NEXT:    movl $1, %edx
; LINUXOSX64-NEXT:    callq test_argv8i1
; LINUXOSX64-NEXT:    popq %rcx
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 8
; LINUXOSX64-NEXT:    retq
entry:
  %v0 = bitcast i8 1 to <8 x i1>
  %call = call x86_regcallcc i8 @test_argv8i1(<8 x i1> %v0, <8 x i1> %v0, <8 x i1> %v0)
  ret i8 %call
}

; Test regcall when returning v8i1 type
define x86_regcallcc <8 x i1> @test_retv8i1()  {
; X32-LABEL: test_retv8i1:
; X32:       # %bb.0:
; X32-NEXT:    movb $1, %al
; X32-NEXT:    retl
;
; CHECK64-LABEL: test_retv8i1:
; CHECK64:       # %bb.0:
; CHECK64-NEXT:    movb $1, %al
; CHECK64-NEXT:    retq
  %a = bitcast i8 1 to <8 x i1>
  ret <8 x i1> %a
}

; Test regcall when processing result of v8i1 type
define <8 x i1> @caller_retv8i1() #0 {
; X32-LABEL: caller_retv8i1:
; X32:       # %bb.0: # %entry
; X32-NEXT:    calll _test_retv8i1
; X32-NEXT:    # kill: def $al killed $al def $eax
; X32-NEXT:    kmovd %eax, %k0
; X32-NEXT:    vpmovm2w %k0, %zmm0
; X32-NEXT:    # kill: def $xmm0 killed $xmm0 killed $zmm0
; X32-NEXT:    vzeroupper
; X32-NEXT:    retl
;
; WIN64-LABEL: caller_retv8i1:
; WIN64:       # %bb.0: # %entry
; WIN64-NEXT:    pushq %rsi
; WIN64-NEXT:    .seh_pushreg %rsi
; WIN64-NEXT:    pushq %rdi
; WIN64-NEXT:    .seh_pushreg %rdi
; WIN64-NEXT:    subq $40, %rsp
; WIN64-NEXT:    .seh_stackalloc 40
; WIN64-NEXT:    vmovaps %xmm7, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
; WIN64-NEXT:    .seh_savexmm %xmm7, 16
; WIN64-NEXT:    vmovaps %xmm6, (%rsp) # 16-byte Spill
; WIN64-NEXT:    .seh_savexmm %xmm6, 0
; WIN64-NEXT:    .seh_endprologue
; WIN64-NEXT:    callq test_retv8i1
; WIN64-NEXT:    # kill: def $al killed $al def $eax
; WIN64-NEXT:    kmovd %eax, %k0
; WIN64-NEXT:    vpmovm2w %k0, %zmm0
; WIN64-NEXT:    # kill: def $xmm0 killed $xmm0 killed $zmm0
; WIN64-NEXT:    vmovaps (%rsp), %xmm6 # 16-byte Reload
; WIN64-NEXT:    vmovaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm7 # 16-byte Reload
; WIN64-NEXT:    addq $40, %rsp
; WIN64-NEXT:    popq %rdi
; WIN64-NEXT:    popq %rsi
; WIN64-NEXT:    vzeroupper
; WIN64-NEXT:    retq
; WIN64-NEXT:    .seh_handlerdata
; WIN64-NEXT:    .text
; WIN64-NEXT:    .seh_endproc
;
; LINUXOSX64-LABEL: caller_retv8i1:
; LINUXOSX64:       # %bb.0: # %entry
; LINUXOSX64-NEXT:    pushq %rax
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 16
; LINUXOSX64-NEXT:    callq test_retv8i1
; LINUXOSX64-NEXT:    # kill: def $al killed $al def $eax
; LINUXOSX64-NEXT:    kmovd %eax, %k0
; LINUXOSX64-NEXT:    vpmovm2w %k0, %zmm0
; LINUXOSX64-NEXT:    # kill: def $xmm0 killed $xmm0 killed $zmm0
; LINUXOSX64-NEXT:    popq %rax
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 8
; LINUXOSX64-NEXT:    vzeroupper
; LINUXOSX64-NEXT:    retq
entry:
  %call = call x86_regcallcc <8 x i1> @test_retv8i1()
  ret <8 x i1> %call
}