1/* 2Copyright (c) 2014, Intel Corporation 3All rights reserved. 4 5Redistribution and use in source and binary forms, with or without 6modification, are permitted provided that the following conditions are met: 7 8 * Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 11 * Redistributions in binary form must reproduce the above copyright notice, 12 * this list of conditions and the following disclaimer in the documentation 13 * and/or other materials provided with the distribution. 14 15 * Neither the name of Intel Corporation nor the names of its contributors 16 * may be used to endorse or promote products derived from this software 17 * without specific prior written permission. 18 19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 23ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29*/ 30 31 32#ifndef MEMCMP 33# define MEMCMP memcmp 34#endif 35 36#ifndef L 37# define L(label) .L##label 38#endif 39 40#ifndef ALIGN 41# define ALIGN(n) .p2align n 42#endif 43 44#ifndef cfi_startproc 45# define cfi_startproc .cfi_startproc 46#endif 47 48#ifndef cfi_endproc 49# define cfi_endproc .cfi_endproc 50#endif 51 52#ifndef ENTRY 53# define ENTRY(name) \ 54 .type name, @function; \ 55 .globl name; \ 56 .p2align 4; \ 57name: \ 58 cfi_startproc 59#endif 60 61#ifndef END 62# define END(name) \ 63 cfi_endproc; \ 64 .size name, .-name 65#endif 66 67#ifndef ALIGN 68# define ALIGN(n) .p2align n 69#endif 70 71#define JMPTBL(I, B) (I - B) 72 73#define BRANCH_TO_JMPTBL_ENTRY(TABLE, INDEX, SCALE) \ 74 lea TABLE(%rip), %r11; \ 75 movslq (%r11, INDEX, SCALE), %rcx; \ 76 add %r11, %rcx; \ 77 jmp *%rcx; \ 78 ud2 79 80 .section .text.sse4.1,"ax",@progbits 81ENTRY (MEMCMP) 82#ifdef USE_AS_WMEMCMP 83 shl $2, %rdx 84#endif 85 pxor %xmm0, %xmm0 86 cmp $79, %rdx 87 ja L(79bytesormore) 88#ifndef USE_AS_WMEMCMP 89 cmp $1, %rdx 90 je L(firstbyte) 91#endif 92 add %rdx, %rsi 93 add %rdx, %rdi 94 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4) 95 96#ifndef USE_AS_WMEMCMP 97 ALIGN (4) 98L(firstbyte): 99 movzbl (%rdi), %eax 100 movzbl (%rsi), %ecx 101 sub %ecx, %eax 102 ret 103#endif 104 105 ALIGN (4) 106L(79bytesormore): 107 movdqu (%rsi), %xmm1 108 movdqu (%rdi), %xmm2 109 pxor %xmm1, %xmm2 110 ptest %xmm2, %xmm0 111 jnc L(16bytesin256) 112 mov %rsi, %rcx 113 and $-16, %rsi 114 add $16, %rsi 115 sub %rsi, %rcx 116 117 sub %rcx, %rdi 118 add %rcx, %rdx 119 test $0xf, %rdi 120 jz L(2aligned) 121 122 cmp $128, %rdx 123 ja L(128bytesormore) 124L(less128bytes): 125 sub $64, %rdx 126 127 movdqu (%rdi), %xmm2 128 pxor (%rsi), %xmm2 129 ptest %xmm2, %xmm0 130 jnc L(16bytesin256) 131 132 movdqu 16(%rdi), %xmm2 133 pxor 16(%rsi), %xmm2 134 ptest %xmm2, %xmm0 135 jnc L(32bytesin256) 136 137 movdqu 32(%rdi), %xmm2 138 pxor 32(%rsi), %xmm2 139 ptest %xmm2, %xmm0 140 jnc L(48bytesin256) 141 142 movdqu 48(%rdi), %xmm2 143 pxor 48(%rsi), %xmm2 144 ptest %xmm2, %xmm0 145 jnc L(64bytesin256) 146 cmp $32, %rdx 147 jb L(less32bytesin64) 148 149 movdqu 64(%rdi), %xmm2 150 pxor 64(%rsi), %xmm2 151 ptest %xmm2, %xmm0 152 jnc L(80bytesin256) 153 154 movdqu 80(%rdi), %xmm2 155 pxor 80(%rsi), %xmm2 156 ptest %xmm2, %xmm0 157 jnc L(96bytesin256) 158 sub $32, %rdx 159 add $32, %rdi 160 add $32, %rsi 161L(less32bytesin64): 162 add $64, %rdi 163 add $64, %rsi 164 add %rdx, %rsi 165 add %rdx, %rdi 166 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4) 167 168L(128bytesormore): 169 cmp $512, %rdx 170 ja L(512bytesormore) 171 cmp $256, %rdx 172 ja L(less512bytes) 173L(less256bytes): 174 sub $128, %rdx 175 176 movdqu (%rdi), %xmm2 177 pxor (%rsi), %xmm2 178 ptest %xmm2, %xmm0 179 jnc L(16bytesin256) 180 181 movdqu 16(%rdi), %xmm2 182 pxor 16(%rsi), %xmm2 183 ptest %xmm2, %xmm0 184 jnc L(32bytesin256) 185 186 movdqu 32(%rdi), %xmm2 187 pxor 32(%rsi), %xmm2 188 ptest %xmm2, %xmm0 189 jnc L(48bytesin256) 190 191 movdqu 48(%rdi), %xmm2 192 pxor 48(%rsi), %xmm2 193 ptest %xmm2, %xmm0 194 jnc L(64bytesin256) 195 196 movdqu 64(%rdi), %xmm2 197 pxor 64(%rsi), %xmm2 198 ptest %xmm2, %xmm0 199 jnc L(80bytesin256) 200 201 movdqu 80(%rdi), %xmm2 202 pxor 80(%rsi), %xmm2 203 ptest %xmm2, %xmm0 204 jnc L(96bytesin256) 205 206 movdqu 96(%rdi), %xmm2 207 pxor 96(%rsi), %xmm2 208 ptest %xmm2, %xmm0 209 jnc L(112bytesin256) 210 211 movdqu 112(%rdi), %xmm2 212 pxor 112(%rsi), %xmm2 213 ptest %xmm2, %xmm0 214 jnc L(128bytesin256) 215 216 add $128, %rsi 217 add $128, %rdi 218 219 cmp $64, %rdx 220 jae L(less128bytes) 221 222 cmp $32, %rdx 223 jb L(less32bytesin128) 224 225 movdqu (%rdi), %xmm2 226 pxor (%rsi), %xmm2 227 ptest %xmm2, %xmm0 228 jnc L(16bytesin256) 229 230 movdqu 16(%rdi), %xmm2 231 pxor 16(%rsi), %xmm2 232 ptest %xmm2, %xmm0 233 jnc L(32bytesin256) 234 sub $32, %rdx 235 add $32, %rdi 236 add $32, %rsi 237L(less32bytesin128): 238 add %rdx, %rsi 239 add %rdx, %rdi 240 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4) 241 242L(less512bytes): 243 sub $256, %rdx 244 movdqu (%rdi), %xmm2 245 pxor (%rsi), %xmm2 246 ptest %xmm2, %xmm0 247 jnc L(16bytesin256) 248 249 movdqu 16(%rdi), %xmm2 250 pxor 16(%rsi), %xmm2 251 ptest %xmm2, %xmm0 252 jnc L(32bytesin256) 253 254 movdqu 32(%rdi), %xmm2 255 pxor 32(%rsi), %xmm2 256 ptest %xmm2, %xmm0 257 jnc L(48bytesin256) 258 259 movdqu 48(%rdi), %xmm2 260 pxor 48(%rsi), %xmm2 261 ptest %xmm2, %xmm0 262 jnc L(64bytesin256) 263 264 movdqu 64(%rdi), %xmm2 265 pxor 64(%rsi), %xmm2 266 ptest %xmm2, %xmm0 267 jnc L(80bytesin256) 268 269 movdqu 80(%rdi), %xmm2 270 pxor 80(%rsi), %xmm2 271 ptest %xmm2, %xmm0 272 jnc L(96bytesin256) 273 274 movdqu 96(%rdi), %xmm2 275 pxor 96(%rsi), %xmm2 276 ptest %xmm2, %xmm0 277 jnc L(112bytesin256) 278 279 movdqu 112(%rdi), %xmm2 280 pxor 112(%rsi), %xmm2 281 ptest %xmm2, %xmm0 282 jnc L(128bytesin256) 283 284 movdqu 128(%rdi), %xmm2 285 pxor 128(%rsi), %xmm2 286 ptest %xmm2, %xmm0 287 jnc L(144bytesin256) 288 289 movdqu 144(%rdi), %xmm2 290 pxor 144(%rsi), %xmm2 291 ptest %xmm2, %xmm0 292 jnc L(160bytesin256) 293 294 movdqu 160(%rdi), %xmm2 295 pxor 160(%rsi), %xmm2 296 ptest %xmm2, %xmm0 297 jnc L(176bytesin256) 298 299 movdqu 176(%rdi), %xmm2 300 pxor 176(%rsi), %xmm2 301 ptest %xmm2, %xmm0 302 jnc L(192bytesin256) 303 304 movdqu 192(%rdi), %xmm2 305 pxor 192(%rsi), %xmm2 306 ptest %xmm2, %xmm0 307 jnc L(208bytesin256) 308 309 movdqu 208(%rdi), %xmm2 310 pxor 208(%rsi), %xmm2 311 ptest %xmm2, %xmm0 312 jnc L(224bytesin256) 313 314 movdqu 224(%rdi), %xmm2 315 pxor 224(%rsi), %xmm2 316 ptest %xmm2, %xmm0 317 jnc L(240bytesin256) 318 319 movdqu 240(%rdi), %xmm2 320 pxor 240(%rsi), %xmm2 321 ptest %xmm2, %xmm0 322 jnc L(256bytesin256) 323 324 add $256, %rsi 325 add $256, %rdi 326 327 cmp $128, %rdx 328 jae L(less256bytes) 329 330 cmp $64, %rdx 331 jae L(less128bytes) 332 333 cmp $32, %rdx 334 jb L(less32bytesin256) 335 336 movdqu (%rdi), %xmm2 337 pxor (%rsi), %xmm2 338 ptest %xmm2, %xmm0 339 jnc L(16bytesin256) 340 341 movdqu 16(%rdi), %xmm2 342 pxor 16(%rsi), %xmm2 343 ptest %xmm2, %xmm0 344 jnc L(32bytesin256) 345 sub $32, %rdx 346 add $32, %rdi 347 add $32, %rsi 348L(less32bytesin256): 349 add %rdx, %rsi 350 add %rdx, %rdi 351 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4) 352 353 ALIGN (4) 354L(512bytesormore): 355 mov __x86_data_cache_size_half(%rip), %r8 356 mov %r8, %r9 357 shr $1, %r8 358 add %r9, %r8 359 cmp %r8, %rdx 360 ja L(L2_L3_cache_unaglined) 361 sub $64, %rdx 362 ALIGN (4) 363L(64bytesormore_loop): 364 movdqu (%rdi), %xmm2 365 pxor (%rsi), %xmm2 366 movdqa %xmm2, %xmm1 367 368 movdqu 16(%rdi), %xmm3 369 pxor 16(%rsi), %xmm3 370 por %xmm3, %xmm1 371 372 movdqu 32(%rdi), %xmm4 373 pxor 32(%rsi), %xmm4 374 por %xmm4, %xmm1 375 376 movdqu 48(%rdi), %xmm5 377 pxor 48(%rsi), %xmm5 378 por %xmm5, %xmm1 379 380 ptest %xmm1, %xmm0 381 jnc L(64bytesormore_loop_end) 382 add $64, %rsi 383 add $64, %rdi 384 sub $64, %rdx 385 jae L(64bytesormore_loop) 386 387 add $64, %rdx 388 add %rdx, %rsi 389 add %rdx, %rdi 390 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4) 391 392L(L2_L3_cache_unaglined): 393 sub $64, %rdx 394 ALIGN (4) 395L(L2_L3_unaligned_128bytes_loop): 396 prefetchnta 0x1c0(%rdi) 397 prefetchnta 0x1c0(%rsi) 398 movdqu (%rdi), %xmm2 399 pxor (%rsi), %xmm2 400 movdqa %xmm2, %xmm1 401 402 movdqu 16(%rdi), %xmm3 403 pxor 16(%rsi), %xmm3 404 por %xmm3, %xmm1 405 406 movdqu 32(%rdi), %xmm4 407 pxor 32(%rsi), %xmm4 408 por %xmm4, %xmm1 409 410 movdqu 48(%rdi), %xmm5 411 pxor 48(%rsi), %xmm5 412 por %xmm5, %xmm1 413 414 ptest %xmm1, %xmm0 415 jnc L(64bytesormore_loop_end) 416 add $64, %rsi 417 add $64, %rdi 418 sub $64, %rdx 419 jae L(L2_L3_unaligned_128bytes_loop) 420 421 add $64, %rdx 422 add %rdx, %rsi 423 add %rdx, %rdi 424 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4) 425 426/* 427 * This case is for machines which are sensitive for unaligned instructions. 428 */ 429 ALIGN (4) 430L(2aligned): 431 cmp $128, %rdx 432 ja L(128bytesormorein2aligned) 433L(less128bytesin2aligned): 434 sub $64, %rdx 435 436 movdqa (%rdi), %xmm2 437 pxor (%rsi), %xmm2 438 ptest %xmm2, %xmm0 439 jnc L(16bytesin256) 440 441 movdqa 16(%rdi), %xmm2 442 pxor 16(%rsi), %xmm2 443 ptest %xmm2, %xmm0 444 jnc L(32bytesin256) 445 446 movdqa 32(%rdi), %xmm2 447 pxor 32(%rsi), %xmm2 448 ptest %xmm2, %xmm0 449 jnc L(48bytesin256) 450 451 movdqa 48(%rdi), %xmm2 452 pxor 48(%rsi), %xmm2 453 ptest %xmm2, %xmm0 454 jnc L(64bytesin256) 455 cmp $32, %rdx 456 jb L(less32bytesin64in2alinged) 457 458 movdqa 64(%rdi), %xmm2 459 pxor 64(%rsi), %xmm2 460 ptest %xmm2, %xmm0 461 jnc L(80bytesin256) 462 463 movdqa 80(%rdi), %xmm2 464 pxor 80(%rsi), %xmm2 465 ptest %xmm2, %xmm0 466 jnc L(96bytesin256) 467 sub $32, %rdx 468 add $32, %rdi 469 add $32, %rsi 470L(less32bytesin64in2alinged): 471 add $64, %rdi 472 add $64, %rsi 473 add %rdx, %rsi 474 add %rdx, %rdi 475 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4) 476 477 ALIGN (4) 478L(128bytesormorein2aligned): 479 cmp $512, %rdx 480 ja L(512bytesormorein2aligned) 481 cmp $256, %rdx 482 ja L(256bytesormorein2aligned) 483L(less256bytesin2alinged): 484 sub $128, %rdx 485 486 movdqa (%rdi), %xmm2 487 pxor (%rsi), %xmm2 488 ptest %xmm2, %xmm0 489 jnc L(16bytesin256) 490 491 movdqa 16(%rdi), %xmm2 492 pxor 16(%rsi), %xmm2 493 ptest %xmm2, %xmm0 494 jnc L(32bytesin256) 495 496 movdqa 32(%rdi), %xmm2 497 pxor 32(%rsi), %xmm2 498 ptest %xmm2, %xmm0 499 jnc L(48bytesin256) 500 501 movdqa 48(%rdi), %xmm2 502 pxor 48(%rsi), %xmm2 503 ptest %xmm2, %xmm0 504 jnc L(64bytesin256) 505 506 movdqa 64(%rdi), %xmm2 507 pxor 64(%rsi), %xmm2 508 ptest %xmm2, %xmm0 509 jnc L(80bytesin256) 510 511 movdqa 80(%rdi), %xmm2 512 pxor 80(%rsi), %xmm2 513 ptest %xmm2, %xmm0 514 jnc L(96bytesin256) 515 516 movdqa 96(%rdi), %xmm2 517 pxor 96(%rsi), %xmm2 518 ptest %xmm2, %xmm0 519 jnc L(112bytesin256) 520 521 movdqa 112(%rdi), %xmm2 522 pxor 112(%rsi), %xmm2 523 ptest %xmm2, %xmm0 524 jnc L(128bytesin256) 525 526 add $128, %rsi 527 add $128, %rdi 528 529 cmp $64, %rdx 530 jae L(less128bytesin2aligned) 531 532 cmp $32, %rdx 533 jb L(less32bytesin128in2aligned) 534 535 movdqu (%rdi), %xmm2 536 pxor (%rsi), %xmm2 537 ptest %xmm2, %xmm0 538 jnc L(16bytesin256) 539 540 movdqu 16(%rdi), %xmm2 541 pxor 16(%rsi), %xmm2 542 ptest %xmm2, %xmm0 543 jnc L(32bytesin256) 544 sub $32, %rdx 545 add $32, %rdi 546 add $32, %rsi 547L(less32bytesin128in2aligned): 548 add %rdx, %rsi 549 add %rdx, %rdi 550 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4) 551 552 ALIGN (4) 553L(256bytesormorein2aligned): 554 555 sub $256, %rdx 556 movdqa (%rdi), %xmm2 557 pxor (%rsi), %xmm2 558 ptest %xmm2, %xmm0 559 jnc L(16bytesin256) 560 561 movdqa 16(%rdi), %xmm2 562 pxor 16(%rsi), %xmm2 563 ptest %xmm2, %xmm0 564 jnc L(32bytesin256) 565 566 movdqa 32(%rdi), %xmm2 567 pxor 32(%rsi), %xmm2 568 ptest %xmm2, %xmm0 569 jnc L(48bytesin256) 570 571 movdqa 48(%rdi), %xmm2 572 pxor 48(%rsi), %xmm2 573 ptest %xmm2, %xmm0 574 jnc L(64bytesin256) 575 576 movdqa 64(%rdi), %xmm2 577 pxor 64(%rsi), %xmm2 578 ptest %xmm2, %xmm0 579 jnc L(80bytesin256) 580 581 movdqa 80(%rdi), %xmm2 582 pxor 80(%rsi), %xmm2 583 ptest %xmm2, %xmm0 584 jnc L(96bytesin256) 585 586 movdqa 96(%rdi), %xmm2 587 pxor 96(%rsi), %xmm2 588 ptest %xmm2, %xmm0 589 jnc L(112bytesin256) 590 591 movdqa 112(%rdi), %xmm2 592 pxor 112(%rsi), %xmm2 593 ptest %xmm2, %xmm0 594 jnc L(128bytesin256) 595 596 movdqa 128(%rdi), %xmm2 597 pxor 128(%rsi), %xmm2 598 ptest %xmm2, %xmm0 599 jnc L(144bytesin256) 600 601 movdqa 144(%rdi), %xmm2 602 pxor 144(%rsi), %xmm2 603 ptest %xmm2, %xmm0 604 jnc L(160bytesin256) 605 606 movdqa 160(%rdi), %xmm2 607 pxor 160(%rsi), %xmm2 608 ptest %xmm2, %xmm0 609 jnc L(176bytesin256) 610 611 movdqa 176(%rdi), %xmm2 612 pxor 176(%rsi), %xmm2 613 ptest %xmm2, %xmm0 614 jnc L(192bytesin256) 615 616 movdqa 192(%rdi), %xmm2 617 pxor 192(%rsi), %xmm2 618 ptest %xmm2, %xmm0 619 jnc L(208bytesin256) 620 621 movdqa 208(%rdi), %xmm2 622 pxor 208(%rsi), %xmm2 623 ptest %xmm2, %xmm0 624 jnc L(224bytesin256) 625 626 movdqa 224(%rdi), %xmm2 627 pxor 224(%rsi), %xmm2 628 ptest %xmm2, %xmm0 629 jnc L(240bytesin256) 630 631 movdqa 240(%rdi), %xmm2 632 pxor 240(%rsi), %xmm2 633 ptest %xmm2, %xmm0 634 jnc L(256bytesin256) 635 636 add $256, %rsi 637 add $256, %rdi 638 639 cmp $128, %rdx 640 jae L(less256bytesin2alinged) 641 642 cmp $64, %rdx 643 jae L(less128bytesin2aligned) 644 645 cmp $32, %rdx 646 jb L(less32bytesin256in2alinged) 647 648 movdqa (%rdi), %xmm2 649 pxor (%rsi), %xmm2 650 ptest %xmm2, %xmm0 651 jnc L(16bytesin256) 652 653 movdqa 16(%rdi), %xmm2 654 pxor 16(%rsi), %xmm2 655 ptest %xmm2, %xmm0 656 jnc L(32bytesin256) 657 sub $32, %rdx 658 add $32, %rdi 659 add $32, %rsi 660L(less32bytesin256in2alinged): 661 add %rdx, %rsi 662 add %rdx, %rdi 663 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4) 664 665 ALIGN (4) 666L(512bytesormorein2aligned): 667 mov __x86_data_cache_size_half(%rip), %r8 668 mov %r8, %r9 669 shr $1, %r8 670 add %r9, %r8 671 cmp %r8, %rdx 672 ja L(L2_L3_cache_aglined) 673 674 sub $64, %rdx 675 ALIGN (4) 676L(64bytesormore_loopin2aligned): 677 movdqa (%rdi), %xmm2 678 pxor (%rsi), %xmm2 679 movdqa %xmm2, %xmm1 680 681 movdqa 16(%rdi), %xmm3 682 pxor 16(%rsi), %xmm3 683 por %xmm3, %xmm1 684 685 movdqa 32(%rdi), %xmm4 686 pxor 32(%rsi), %xmm4 687 por %xmm4, %xmm1 688 689 movdqa 48(%rdi), %xmm5 690 pxor 48(%rsi), %xmm5 691 por %xmm5, %xmm1 692 693 ptest %xmm1, %xmm0 694 jnc L(64bytesormore_loop_end) 695 add $64, %rsi 696 add $64, %rdi 697 sub $64, %rdx 698 jae L(64bytesormore_loopin2aligned) 699 700 add $64, %rdx 701 add %rdx, %rsi 702 add %rdx, %rdi 703 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4) 704L(L2_L3_cache_aglined): 705 sub $64, %rdx 706 ALIGN (4) 707L(L2_L3_aligned_128bytes_loop): 708 prefetchnta 0x1c0(%rdi) 709 prefetchnta 0x1c0(%rsi) 710 movdqa (%rdi), %xmm2 711 pxor (%rsi), %xmm2 712 movdqa %xmm2, %xmm1 713 714 movdqa 16(%rdi), %xmm3 715 pxor 16(%rsi), %xmm3 716 por %xmm3, %xmm1 717 718 movdqa 32(%rdi), %xmm4 719 pxor 32(%rsi), %xmm4 720 por %xmm4, %xmm1 721 722 movdqa 48(%rdi), %xmm5 723 pxor 48(%rsi), %xmm5 724 por %xmm5, %xmm1 725 726 ptest %xmm1, %xmm0 727 jnc L(64bytesormore_loop_end) 728 add $64, %rsi 729 add $64, %rdi 730 sub $64, %rdx 731 jae L(L2_L3_aligned_128bytes_loop) 732 733 add $64, %rdx 734 add %rdx, %rsi 735 add %rdx, %rdi 736 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4) 737 738 739 ALIGN (4) 740L(64bytesormore_loop_end): 741 add $16, %rdi 742 add $16, %rsi 743 ptest %xmm2, %xmm0 744 jnc L(16bytes) 745 746 add $16, %rdi 747 add $16, %rsi 748 ptest %xmm3, %xmm0 749 jnc L(16bytes) 750 751 add $16, %rdi 752 add $16, %rsi 753 ptest %xmm4, %xmm0 754 jnc L(16bytes) 755 756 add $16, %rdi 757 add $16, %rsi 758 jmp L(16bytes) 759 760L(256bytesin256): 761 add $256, %rdi 762 add $256, %rsi 763 jmp L(16bytes) 764L(240bytesin256): 765 add $240, %rdi 766 add $240, %rsi 767 jmp L(16bytes) 768L(224bytesin256): 769 add $224, %rdi 770 add $224, %rsi 771 jmp L(16bytes) 772L(208bytesin256): 773 add $208, %rdi 774 add $208, %rsi 775 jmp L(16bytes) 776L(192bytesin256): 777 add $192, %rdi 778 add $192, %rsi 779 jmp L(16bytes) 780L(176bytesin256): 781 add $176, %rdi 782 add $176, %rsi 783 jmp L(16bytes) 784L(160bytesin256): 785 add $160, %rdi 786 add $160, %rsi 787 jmp L(16bytes) 788L(144bytesin256): 789 add $144, %rdi 790 add $144, %rsi 791 jmp L(16bytes) 792L(128bytesin256): 793 add $128, %rdi 794 add $128, %rsi 795 jmp L(16bytes) 796L(112bytesin256): 797 add $112, %rdi 798 add $112, %rsi 799 jmp L(16bytes) 800L(96bytesin256): 801 add $96, %rdi 802 add $96, %rsi 803 jmp L(16bytes) 804L(80bytesin256): 805 add $80, %rdi 806 add $80, %rsi 807 jmp L(16bytes) 808L(64bytesin256): 809 add $64, %rdi 810 add $64, %rsi 811 jmp L(16bytes) 812L(48bytesin256): 813 add $16, %rdi 814 add $16, %rsi 815L(32bytesin256): 816 add $16, %rdi 817 add $16, %rsi 818L(16bytesin256): 819 add $16, %rdi 820 add $16, %rsi 821L(16bytes): 822 mov -16(%rdi), %rax 823 mov -16(%rsi), %rcx 824 cmp %rax, %rcx 825 jne L(diffin8bytes) 826L(8bytes): 827 mov -8(%rdi), %rax 828 mov -8(%rsi), %rcx 829 cmp %rax, %rcx 830 jne L(diffin8bytes) 831 xor %eax, %eax 832 ret 833 834 ALIGN (4) 835L(12bytes): 836 mov -12(%rdi), %rax 837 mov -12(%rsi), %rcx 838 cmp %rax, %rcx 839 jne L(diffin8bytes) 840L(4bytes): 841 mov -4(%rsi), %ecx 842 mov -4(%rdi), %eax 843 cmp %eax, %ecx 844 jne L(diffin4bytes) 845L(0bytes): 846 xor %eax, %eax 847 ret 848 849#ifndef USE_AS_WMEMCMP 850/* unreal case for wmemcmp */ 851 ALIGN (4) 852L(65bytes): 853 movdqu -65(%rdi), %xmm1 854 movdqu -65(%rsi), %xmm2 855 mov $-65, %dl 856 pxor %xmm1, %xmm2 857 ptest %xmm2, %xmm0 858 jnc L(less16bytes) 859L(49bytes): 860 movdqu -49(%rdi), %xmm1 861 movdqu -49(%rsi), %xmm2 862 mov $-49, %dl 863 pxor %xmm1, %xmm2 864 ptest %xmm2, %xmm0 865 jnc L(less16bytes) 866L(33bytes): 867 movdqu -33(%rdi), %xmm1 868 movdqu -33(%rsi), %xmm2 869 mov $-33, %dl 870 pxor %xmm1, %xmm2 871 ptest %xmm2, %xmm0 872 jnc L(less16bytes) 873L(17bytes): 874 mov -17(%rdi), %rax 875 mov -17(%rsi), %rcx 876 cmp %rax, %rcx 877 jne L(diffin8bytes) 878L(9bytes): 879 mov -9(%rdi), %rax 880 mov -9(%rsi), %rcx 881 cmp %rax, %rcx 882 jne L(diffin8bytes) 883 movzbl -1(%rdi), %eax 884 movzbl -1(%rsi), %edx 885 sub %edx, %eax 886 ret 887 888 ALIGN (4) 889L(13bytes): 890 mov -13(%rdi), %rax 891 mov -13(%rsi), %rcx 892 cmp %rax, %rcx 893 jne L(diffin8bytes) 894 mov -8(%rdi), %rax 895 mov -8(%rsi), %rcx 896 cmp %rax, %rcx 897 jne L(diffin8bytes) 898 xor %eax, %eax 899 ret 900 901 ALIGN (4) 902L(5bytes): 903 mov -5(%rdi), %eax 904 mov -5(%rsi), %ecx 905 cmp %eax, %ecx 906 jne L(diffin4bytes) 907 movzbl -1(%rdi), %eax 908 movzbl -1(%rsi), %edx 909 sub %edx, %eax 910 ret 911 912 ALIGN (4) 913L(66bytes): 914 movdqu -66(%rdi), %xmm1 915 movdqu -66(%rsi), %xmm2 916 mov $-66, %dl 917 pxor %xmm1, %xmm2 918 ptest %xmm2, %xmm0 919 jnc L(less16bytes) 920L(50bytes): 921 movdqu -50(%rdi), %xmm1 922 movdqu -50(%rsi), %xmm2 923 mov $-50, %dl 924 pxor %xmm1, %xmm2 925 ptest %xmm2, %xmm0 926 jnc L(less16bytes) 927L(34bytes): 928 movdqu -34(%rdi), %xmm1 929 movdqu -34(%rsi), %xmm2 930 mov $-34, %dl 931 pxor %xmm1, %xmm2 932 ptest %xmm2, %xmm0 933 jnc L(less16bytes) 934L(18bytes): 935 mov -18(%rdi), %rax 936 mov -18(%rsi), %rcx 937 cmp %rax, %rcx 938 jne L(diffin8bytes) 939L(10bytes): 940 mov -10(%rdi), %rax 941 mov -10(%rsi), %rcx 942 cmp %rax, %rcx 943 jne L(diffin8bytes) 944 movzwl -2(%rdi), %eax 945 movzwl -2(%rsi), %ecx 946 cmp %cl, %al 947 jne L(end) 948 and $0xffff, %eax 949 and $0xffff, %ecx 950 sub %ecx, %eax 951 ret 952 953 ALIGN (4) 954L(14bytes): 955 mov -14(%rdi), %rax 956 mov -14(%rsi), %rcx 957 cmp %rax, %rcx 958 jne L(diffin8bytes) 959 mov -8(%rdi), %rax 960 mov -8(%rsi), %rcx 961 cmp %rax, %rcx 962 jne L(diffin8bytes) 963 xor %eax, %eax 964 ret 965 966 ALIGN (4) 967L(6bytes): 968 mov -6(%rdi), %eax 969 mov -6(%rsi), %ecx 970 cmp %eax, %ecx 971 jne L(diffin4bytes) 972L(2bytes): 973 movzwl -2(%rsi), %ecx 974 movzwl -2(%rdi), %eax 975 cmp %cl, %al 976 jne L(end) 977 and $0xffff, %eax 978 and $0xffff, %ecx 979 sub %ecx, %eax 980 ret 981 982 ALIGN (4) 983L(67bytes): 984 movdqu -67(%rdi), %xmm2 985 movdqu -67(%rsi), %xmm1 986 mov $-67, %dl 987 pxor %xmm1, %xmm2 988 ptest %xmm2, %xmm0 989 jnc L(less16bytes) 990L(51bytes): 991 movdqu -51(%rdi), %xmm2 992 movdqu -51(%rsi), %xmm1 993 mov $-51, %dl 994 pxor %xmm1, %xmm2 995 ptest %xmm2, %xmm0 996 jnc L(less16bytes) 997L(35bytes): 998 movdqu -35(%rsi), %xmm1 999 movdqu -35(%rdi), %xmm2 1000 mov $-35, %dl 1001 pxor %xmm1, %xmm2 1002 ptest %xmm2, %xmm0 1003 jnc L(less16bytes) 1004L(19bytes): 1005 mov -19(%rdi), %rax 1006 mov -19(%rsi), %rcx 1007 cmp %rax, %rcx 1008 jne L(diffin8bytes) 1009L(11bytes): 1010 mov -11(%rdi), %rax 1011 mov -11(%rsi), %rcx 1012 cmp %rax, %rcx 1013 jne L(diffin8bytes) 1014 mov -4(%rdi), %eax 1015 mov -4(%rsi), %ecx 1016 cmp %eax, %ecx 1017 jne L(diffin4bytes) 1018 xor %eax, %eax 1019 ret 1020 1021 ALIGN (4) 1022L(15bytes): 1023 mov -15(%rdi), %rax 1024 mov -15(%rsi), %rcx 1025 cmp %rax, %rcx 1026 jne L(diffin8bytes) 1027 mov -8(%rdi), %rax 1028 mov -8(%rsi), %rcx 1029 cmp %rax, %rcx 1030 jne L(diffin8bytes) 1031 xor %eax, %eax 1032 ret 1033 1034 ALIGN (4) 1035L(7bytes): 1036 mov -7(%rdi), %eax 1037 mov -7(%rsi), %ecx 1038 cmp %eax, %ecx 1039 jne L(diffin4bytes) 1040 mov -4(%rdi), %eax 1041 mov -4(%rsi), %ecx 1042 cmp %eax, %ecx 1043 jne L(diffin4bytes) 1044 xor %eax, %eax 1045 ret 1046 1047 ALIGN (4) 1048L(3bytes): 1049 movzwl -3(%rdi), %eax 1050 movzwl -3(%rsi), %ecx 1051 cmp %eax, %ecx 1052 jne L(diffin2bytes) 1053L(1bytes): 1054 movzbl -1(%rdi), %eax 1055 movzbl -1(%rsi), %ecx 1056 sub %ecx, %eax 1057 ret 1058#endif 1059 1060 ALIGN (4) 1061L(68bytes): 1062 movdqu -68(%rdi), %xmm2 1063 movdqu -68(%rsi), %xmm1 1064 mov $-68, %dl 1065 pxor %xmm1, %xmm2 1066 ptest %xmm2, %xmm0 1067 jnc L(less16bytes) 1068L(52bytes): 1069 movdqu -52(%rdi), %xmm2 1070 movdqu -52(%rsi), %xmm1 1071 mov $-52, %dl 1072 pxor %xmm1, %xmm2 1073 ptest %xmm2, %xmm0 1074 jnc L(less16bytes) 1075L(36bytes): 1076 movdqu -36(%rdi), %xmm2 1077 movdqu -36(%rsi), %xmm1 1078 mov $-36, %dl 1079 pxor %xmm1, %xmm2 1080 ptest %xmm2, %xmm0 1081 jnc L(less16bytes) 1082L(20bytes): 1083 movdqu -20(%rdi), %xmm2 1084 movdqu -20(%rsi), %xmm1 1085 mov $-20, %dl 1086 pxor %xmm1, %xmm2 1087 ptest %xmm2, %xmm0 1088 jnc L(less16bytes) 1089 mov -4(%rdi), %eax 1090 mov -4(%rsi), %ecx 1091 cmp %eax, %ecx 1092 jne L(diffin4bytes) 1093 xor %eax, %eax 1094 ret 1095 1096#ifndef USE_AS_WMEMCMP 1097/* unreal cases for wmemcmp */ 1098 ALIGN (4) 1099L(69bytes): 1100 movdqu -69(%rsi), %xmm1 1101 movdqu -69(%rdi), %xmm2 1102 mov $-69, %dl 1103 pxor %xmm1, %xmm2 1104 ptest %xmm2, %xmm0 1105 jnc L(less16bytes) 1106L(53bytes): 1107 movdqu -53(%rsi), %xmm1 1108 movdqu -53(%rdi), %xmm2 1109 mov $-53, %dl 1110 pxor %xmm1, %xmm2 1111 ptest %xmm2, %xmm0 1112 jnc L(less16bytes) 1113L(37bytes): 1114 movdqu -37(%rsi), %xmm1 1115 movdqu -37(%rdi), %xmm2 1116 mov $-37, %dl 1117 pxor %xmm1, %xmm2 1118 ptest %xmm2, %xmm0 1119 jnc L(less16bytes) 1120L(21bytes): 1121 movdqu -21(%rsi), %xmm1 1122 movdqu -21(%rdi), %xmm2 1123 mov $-21, %dl 1124 pxor %xmm1, %xmm2 1125 ptest %xmm2, %xmm0 1126 jnc L(less16bytes) 1127 mov -8(%rdi), %rax 1128 mov -8(%rsi), %rcx 1129 cmp %rax, %rcx 1130 jne L(diffin8bytes) 1131 xor %eax, %eax 1132 ret 1133 1134 ALIGN (4) 1135L(70bytes): 1136 movdqu -70(%rsi), %xmm1 1137 movdqu -70(%rdi), %xmm2 1138 mov $-70, %dl 1139 pxor %xmm1, %xmm2 1140 ptest %xmm2, %xmm0 1141 jnc L(less16bytes) 1142L(54bytes): 1143 movdqu -54(%rsi), %xmm1 1144 movdqu -54(%rdi), %xmm2 1145 mov $-54, %dl 1146 pxor %xmm1, %xmm2 1147 ptest %xmm2, %xmm0 1148 jnc L(less16bytes) 1149L(38bytes): 1150 movdqu -38(%rsi), %xmm1 1151 movdqu -38(%rdi), %xmm2 1152 mov $-38, %dl 1153 pxor %xmm1, %xmm2 1154 ptest %xmm2, %xmm0 1155 jnc L(less16bytes) 1156L(22bytes): 1157 movdqu -22(%rsi), %xmm1 1158 movdqu -22(%rdi), %xmm2 1159 mov $-22, %dl 1160 pxor %xmm1, %xmm2 1161 ptest %xmm2, %xmm0 1162 jnc L(less16bytes) 1163 mov -8(%rdi), %rax 1164 mov -8(%rsi), %rcx 1165 cmp %rax, %rcx 1166 jne L(diffin8bytes) 1167 xor %eax, %eax 1168 ret 1169 1170 ALIGN (4) 1171L(71bytes): 1172 movdqu -71(%rsi), %xmm1 1173 movdqu -71(%rdi), %xmm2 1174 mov $-71, %dl 1175 pxor %xmm1, %xmm2 1176 ptest %xmm2, %xmm0 1177 jnc L(less16bytes) 1178L(55bytes): 1179 movdqu -55(%rdi), %xmm2 1180 movdqu -55(%rsi), %xmm1 1181 mov $-55, %dl 1182 pxor %xmm1, %xmm2 1183 ptest %xmm2, %xmm0 1184 jnc L(less16bytes) 1185L(39bytes): 1186 movdqu -39(%rdi), %xmm2 1187 movdqu -39(%rsi), %xmm1 1188 mov $-39, %dl 1189 pxor %xmm1, %xmm2 1190 ptest %xmm2, %xmm0 1191 jnc L(less16bytes) 1192L(23bytes): 1193 movdqu -23(%rdi), %xmm2 1194 movdqu -23(%rsi), %xmm1 1195 mov $-23, %dl 1196 pxor %xmm1, %xmm2 1197 ptest %xmm2, %xmm0 1198 jnc L(less16bytes) 1199 mov -8(%rdi), %rax 1200 mov -8(%rsi), %rcx 1201 cmp %rax, %rcx 1202 jne L(diffin8bytes) 1203 xor %eax, %eax 1204 ret 1205#endif 1206 1207 ALIGN (4) 1208L(72bytes): 1209 movdqu -72(%rsi), %xmm1 1210 movdqu -72(%rdi), %xmm2 1211 mov $-72, %dl 1212 pxor %xmm1, %xmm2 1213 ptest %xmm2, %xmm0 1214 jnc L(less16bytes) 1215L(56bytes): 1216 movdqu -56(%rdi), %xmm2 1217 movdqu -56(%rsi), %xmm1 1218 mov $-56, %dl 1219 pxor %xmm1, %xmm2 1220 ptest %xmm2, %xmm0 1221 jnc L(less16bytes) 1222L(40bytes): 1223 movdqu -40(%rdi), %xmm2 1224 movdqu -40(%rsi), %xmm1 1225 mov $-40, %dl 1226 pxor %xmm1, %xmm2 1227 ptest %xmm2, %xmm0 1228 jnc L(less16bytes) 1229L(24bytes): 1230 movdqu -24(%rdi), %xmm2 1231 movdqu -24(%rsi), %xmm1 1232 mov $-24, %dl 1233 pxor %xmm1, %xmm2 1234 ptest %xmm2, %xmm0 1235 jnc L(less16bytes) 1236 mov -8(%rdi), %rax 1237 mov -8(%rsi), %rcx 1238 cmp %rax, %rcx 1239 jne L(diffin8bytes) 1240 xor %eax, %eax 1241 ret 1242 1243#ifndef USE_AS_WMEMCMP 1244/* unreal cases for wmemcmp */ 1245 ALIGN (4) 1246L(73bytes): 1247 movdqu -73(%rsi), %xmm1 1248 movdqu -73(%rdi), %xmm2 1249 mov $-73, %dl 1250 pxor %xmm1, %xmm2 1251 ptest %xmm2, %xmm0 1252 jnc L(less16bytes) 1253L(57bytes): 1254 movdqu -57(%rdi), %xmm2 1255 movdqu -57(%rsi), %xmm1 1256 mov $-57, %dl 1257 pxor %xmm1, %xmm2 1258 ptest %xmm2, %xmm0 1259 jnc L(less16bytes) 1260L(41bytes): 1261 movdqu -41(%rdi), %xmm2 1262 movdqu -41(%rsi), %xmm1 1263 mov $-41, %dl 1264 pxor %xmm1, %xmm2 1265 ptest %xmm2, %xmm0 1266 jnc L(less16bytes) 1267L(25bytes): 1268 movdqu -25(%rdi), %xmm2 1269 movdqu -25(%rsi), %xmm1 1270 mov $-25, %dl 1271 pxor %xmm1, %xmm2 1272 ptest %xmm2, %xmm0 1273 jnc L(less16bytes) 1274 mov -9(%rdi), %rax 1275 mov -9(%rsi), %rcx 1276 cmp %rax, %rcx 1277 jne L(diffin8bytes) 1278 movzbl -1(%rdi), %eax 1279 movzbl -1(%rsi), %ecx 1280 sub %ecx, %eax 1281 ret 1282 1283 ALIGN (4) 1284L(74bytes): 1285 movdqu -74(%rsi), %xmm1 1286 movdqu -74(%rdi), %xmm2 1287 mov $-74, %dl 1288 pxor %xmm1, %xmm2 1289 ptest %xmm2, %xmm0 1290 jnc L(less16bytes) 1291L(58bytes): 1292 movdqu -58(%rdi), %xmm2 1293 movdqu -58(%rsi), %xmm1 1294 mov $-58, %dl 1295 pxor %xmm1, %xmm2 1296 ptest %xmm2, %xmm0 1297 jnc L(less16bytes) 1298L(42bytes): 1299 movdqu -42(%rdi), %xmm2 1300 movdqu -42(%rsi), %xmm1 1301 mov $-42, %dl 1302 pxor %xmm1, %xmm2 1303 ptest %xmm2, %xmm0 1304 jnc L(less16bytes) 1305L(26bytes): 1306 movdqu -26(%rdi), %xmm2 1307 movdqu -26(%rsi), %xmm1 1308 mov $-26, %dl 1309 pxor %xmm1, %xmm2 1310 ptest %xmm2, %xmm0 1311 jnc L(less16bytes) 1312 mov -10(%rdi), %rax 1313 mov -10(%rsi), %rcx 1314 cmp %rax, %rcx 1315 jne L(diffin8bytes) 1316 movzwl -2(%rdi), %eax 1317 movzwl -2(%rsi), %ecx 1318 jmp L(diffin2bytes) 1319 1320 ALIGN (4) 1321L(75bytes): 1322 movdqu -75(%rsi), %xmm1 1323 movdqu -75(%rdi), %xmm2 1324 mov $-75, %dl 1325 pxor %xmm1, %xmm2 1326 ptest %xmm2, %xmm0 1327 jnc L(less16bytes) 1328L(59bytes): 1329 movdqu -59(%rdi), %xmm2 1330 movdqu -59(%rsi), %xmm1 1331 mov $-59, %dl 1332 pxor %xmm1, %xmm2 1333 ptest %xmm2, %xmm0 1334 jnc L(less16bytes) 1335L(43bytes): 1336 movdqu -43(%rdi), %xmm2 1337 movdqu -43(%rsi), %xmm1 1338 mov $-43, %dl 1339 pxor %xmm1, %xmm2 1340 ptest %xmm2, %xmm0 1341 jnc L(less16bytes) 1342L(27bytes): 1343 movdqu -27(%rdi), %xmm2 1344 movdqu -27(%rsi), %xmm1 1345 mov $-27, %dl 1346 pxor %xmm1, %xmm2 1347 ptest %xmm2, %xmm0 1348 jnc L(less16bytes) 1349 mov -11(%rdi), %rax 1350 mov -11(%rsi), %rcx 1351 cmp %rax, %rcx 1352 jne L(diffin8bytes) 1353 mov -4(%rdi), %eax 1354 mov -4(%rsi), %ecx 1355 cmp %eax, %ecx 1356 jne L(diffin4bytes) 1357 xor %eax, %eax 1358 ret 1359#endif 1360 ALIGN (4) 1361L(76bytes): 1362 movdqu -76(%rsi), %xmm1 1363 movdqu -76(%rdi), %xmm2 1364 mov $-76, %dl 1365 pxor %xmm1, %xmm2 1366 ptest %xmm2, %xmm0 1367 jnc L(less16bytes) 1368L(60bytes): 1369 movdqu -60(%rdi), %xmm2 1370 movdqu -60(%rsi), %xmm1 1371 mov $-60, %dl 1372 pxor %xmm1, %xmm2 1373 ptest %xmm2, %xmm0 1374 jnc L(less16bytes) 1375L(44bytes): 1376 movdqu -44(%rdi), %xmm2 1377 movdqu -44(%rsi), %xmm1 1378 mov $-44, %dl 1379 pxor %xmm1, %xmm2 1380 ptest %xmm2, %xmm0 1381 jnc L(less16bytes) 1382L(28bytes): 1383 movdqu -28(%rdi), %xmm2 1384 movdqu -28(%rsi), %xmm1 1385 mov $-28, %dl 1386 pxor %xmm1, %xmm2 1387 ptest %xmm2, %xmm0 1388 jnc L(less16bytes) 1389 mov -12(%rdi), %rax 1390 mov -12(%rsi), %rcx 1391 cmp %rax, %rcx 1392 jne L(diffin8bytes) 1393 mov -4(%rdi), %eax 1394 mov -4(%rsi), %ecx 1395 cmp %eax, %ecx 1396 jne L(diffin4bytes) 1397 xor %eax, %eax 1398 ret 1399 1400#ifndef USE_AS_WMEMCMP 1401/* unreal cases for wmemcmp */ 1402 ALIGN (4) 1403L(77bytes): 1404 movdqu -77(%rsi), %xmm1 1405 movdqu -77(%rdi), %xmm2 1406 mov $-77, %dl 1407 pxor %xmm1, %xmm2 1408 ptest %xmm2, %xmm0 1409 jnc L(less16bytes) 1410L(61bytes): 1411 movdqu -61(%rdi), %xmm2 1412 movdqu -61(%rsi), %xmm1 1413 mov $-61, %dl 1414 pxor %xmm1, %xmm2 1415 ptest %xmm2, %xmm0 1416 jnc L(less16bytes) 1417L(45bytes): 1418 movdqu -45(%rdi), %xmm2 1419 movdqu -45(%rsi), %xmm1 1420 mov $-45, %dl 1421 pxor %xmm1, %xmm2 1422 ptest %xmm2, %xmm0 1423 jnc L(less16bytes) 1424L(29bytes): 1425 movdqu -29(%rdi), %xmm2 1426 movdqu -29(%rsi), %xmm1 1427 mov $-29, %dl 1428 pxor %xmm1, %xmm2 1429 ptest %xmm2, %xmm0 1430 jnc L(less16bytes) 1431 1432 mov -13(%rdi), %rax 1433 mov -13(%rsi), %rcx 1434 cmp %rax, %rcx 1435 jne L(diffin8bytes) 1436 1437 mov -8(%rdi), %rax 1438 mov -8(%rsi), %rcx 1439 cmp %rax, %rcx 1440 jne L(diffin8bytes) 1441 xor %eax, %eax 1442 ret 1443 1444 ALIGN (4) 1445L(78bytes): 1446 movdqu -78(%rsi), %xmm1 1447 movdqu -78(%rdi), %xmm2 1448 mov $-78, %dl 1449 pxor %xmm1, %xmm2 1450 ptest %xmm2, %xmm0 1451 jnc L(less16bytes) 1452L(62bytes): 1453 movdqu -62(%rdi), %xmm2 1454 movdqu -62(%rsi), %xmm1 1455 mov $-62, %dl 1456 pxor %xmm1, %xmm2 1457 ptest %xmm2, %xmm0 1458 jnc L(less16bytes) 1459L(46bytes): 1460 movdqu -46(%rdi), %xmm2 1461 movdqu -46(%rsi), %xmm1 1462 mov $-46, %dl 1463 pxor %xmm1, %xmm2 1464 ptest %xmm2, %xmm0 1465 jnc L(less16bytes) 1466L(30bytes): 1467 movdqu -30(%rdi), %xmm2 1468 movdqu -30(%rsi), %xmm1 1469 mov $-30, %dl 1470 pxor %xmm1, %xmm2 1471 ptest %xmm2, %xmm0 1472 jnc L(less16bytes) 1473 mov -14(%rdi), %rax 1474 mov -14(%rsi), %rcx 1475 cmp %rax, %rcx 1476 jne L(diffin8bytes) 1477 mov -8(%rdi), %rax 1478 mov -8(%rsi), %rcx 1479 cmp %rax, %rcx 1480 jne L(diffin8bytes) 1481 xor %eax, %eax 1482 ret 1483 1484 ALIGN (4) 1485L(79bytes): 1486 movdqu -79(%rsi), %xmm1 1487 movdqu -79(%rdi), %xmm2 1488 mov $-79, %dl 1489 pxor %xmm1, %xmm2 1490 ptest %xmm2, %xmm0 1491 jnc L(less16bytes) 1492L(63bytes): 1493 movdqu -63(%rdi), %xmm2 1494 movdqu -63(%rsi), %xmm1 1495 mov $-63, %dl 1496 pxor %xmm1, %xmm2 1497 ptest %xmm2, %xmm0 1498 jnc L(less16bytes) 1499L(47bytes): 1500 movdqu -47(%rdi), %xmm2 1501 movdqu -47(%rsi), %xmm1 1502 mov $-47, %dl 1503 pxor %xmm1, %xmm2 1504 ptest %xmm2, %xmm0 1505 jnc L(less16bytes) 1506L(31bytes): 1507 movdqu -31(%rdi), %xmm2 1508 movdqu -31(%rsi), %xmm1 1509 mov $-31, %dl 1510 pxor %xmm1, %xmm2 1511 ptest %xmm2, %xmm0 1512 jnc L(less16bytes) 1513 mov -15(%rdi), %rax 1514 mov -15(%rsi), %rcx 1515 cmp %rax, %rcx 1516 jne L(diffin8bytes) 1517 mov -8(%rdi), %rax 1518 mov -8(%rsi), %rcx 1519 cmp %rax, %rcx 1520 jne L(diffin8bytes) 1521 xor %eax, %eax 1522 ret 1523#endif 1524 ALIGN (4) 1525L(64bytes): 1526 movdqu -64(%rdi), %xmm2 1527 movdqu -64(%rsi), %xmm1 1528 mov $-64, %dl 1529 pxor %xmm1, %xmm2 1530 ptest %xmm2, %xmm0 1531 jnc L(less16bytes) 1532L(48bytes): 1533 movdqu -48(%rdi), %xmm2 1534 movdqu -48(%rsi), %xmm1 1535 mov $-48, %dl 1536 pxor %xmm1, %xmm2 1537 ptest %xmm2, %xmm0 1538 jnc L(less16bytes) 1539L(32bytes): 1540 movdqu -32(%rdi), %xmm2 1541 movdqu -32(%rsi), %xmm1 1542 mov $-32, %dl 1543 pxor %xmm1, %xmm2 1544 ptest %xmm2, %xmm0 1545 jnc L(less16bytes) 1546 1547 mov -16(%rdi), %rax 1548 mov -16(%rsi), %rcx 1549 cmp %rax, %rcx 1550 jne L(diffin8bytes) 1551 1552 mov -8(%rdi), %rax 1553 mov -8(%rsi), %rcx 1554 cmp %rax, %rcx 1555 jne L(diffin8bytes) 1556 xor %eax, %eax 1557 ret 1558 1559/* 1560 * Aligned 8 bytes to avoid 2 branch "taken" in one 16 alinged code block. 1561 */ 1562 ALIGN (3) 1563L(less16bytes): 1564 movsbq %dl, %rdx 1565 mov (%rsi, %rdx), %rcx 1566 mov (%rdi, %rdx), %rax 1567 cmp %rax, %rcx 1568 jne L(diffin8bytes) 1569 mov 8(%rsi, %rdx), %rcx 1570 mov 8(%rdi, %rdx), %rax 1571L(diffin8bytes): 1572 cmp %eax, %ecx 1573 jne L(diffin4bytes) 1574 shr $32, %rcx 1575 shr $32, %rax 1576 1577#ifdef USE_AS_WMEMCMP 1578/* for wmemcmp */ 1579 cmp %eax, %ecx 1580 jne L(diffin4bytes) 1581 xor %eax, %eax 1582 ret 1583#endif 1584 1585L(diffin4bytes): 1586#ifndef USE_AS_WMEMCMP 1587 cmp %cx, %ax 1588 jne L(diffin2bytes) 1589 shr $16, %ecx 1590 shr $16, %eax 1591L(diffin2bytes): 1592 cmp %cl, %al 1593 jne L(end) 1594 and $0xffff, %eax 1595 and $0xffff, %ecx 1596 sub %ecx, %eax 1597 ret 1598#else 1599 1600/* for wmemcmp */ 1601 mov $1, %eax 1602 jl L(nequal_bigger) 1603 neg %eax 1604 ret 1605 1606 ALIGN (4) 1607L(nequal_bigger): 1608 ret 1609 1610L(unreal_case): 1611 xor %eax, %eax 1612 ret 1613#endif 1614 1615 ALIGN (4) 1616L(end): 1617 and $0xff, %eax 1618 and $0xff, %ecx 1619 sub %ecx, %eax 1620 ret 1621 1622END (MEMCMP) 1623 1624 .section .rodata.sse4.1,"a",@progbits 1625 ALIGN (3) 1626#ifndef USE_AS_WMEMCMP 1627L(table_64bytes): 1628 .int JMPTBL (L(0bytes), L(table_64bytes)) 1629 .int JMPTBL (L(1bytes), L(table_64bytes)) 1630 .int JMPTBL (L(2bytes), L(table_64bytes)) 1631 .int JMPTBL (L(3bytes), L(table_64bytes)) 1632 .int JMPTBL (L(4bytes), L(table_64bytes)) 1633 .int JMPTBL (L(5bytes), L(table_64bytes)) 1634 .int JMPTBL (L(6bytes), L(table_64bytes)) 1635 .int JMPTBL (L(7bytes), L(table_64bytes)) 1636 .int JMPTBL (L(8bytes), L(table_64bytes)) 1637 .int JMPTBL (L(9bytes), L(table_64bytes)) 1638 .int JMPTBL (L(10bytes), L(table_64bytes)) 1639 .int JMPTBL (L(11bytes), L(table_64bytes)) 1640 .int JMPTBL (L(12bytes), L(table_64bytes)) 1641 .int JMPTBL (L(13bytes), L(table_64bytes)) 1642 .int JMPTBL (L(14bytes), L(table_64bytes)) 1643 .int JMPTBL (L(15bytes), L(table_64bytes)) 1644 .int JMPTBL (L(16bytes), L(table_64bytes)) 1645 .int JMPTBL (L(17bytes), L(table_64bytes)) 1646 .int JMPTBL (L(18bytes), L(table_64bytes)) 1647 .int JMPTBL (L(19bytes), L(table_64bytes)) 1648 .int JMPTBL (L(20bytes), L(table_64bytes)) 1649 .int JMPTBL (L(21bytes), L(table_64bytes)) 1650 .int JMPTBL (L(22bytes), L(table_64bytes)) 1651 .int JMPTBL (L(23bytes), L(table_64bytes)) 1652 .int JMPTBL (L(24bytes), L(table_64bytes)) 1653 .int JMPTBL (L(25bytes), L(table_64bytes)) 1654 .int JMPTBL (L(26bytes), L(table_64bytes)) 1655 .int JMPTBL (L(27bytes), L(table_64bytes)) 1656 .int JMPTBL (L(28bytes), L(table_64bytes)) 1657 .int JMPTBL (L(29bytes), L(table_64bytes)) 1658 .int JMPTBL (L(30bytes), L(table_64bytes)) 1659 .int JMPTBL (L(31bytes), L(table_64bytes)) 1660 .int JMPTBL (L(32bytes), L(table_64bytes)) 1661 .int JMPTBL (L(33bytes), L(table_64bytes)) 1662 .int JMPTBL (L(34bytes), L(table_64bytes)) 1663 .int JMPTBL (L(35bytes), L(table_64bytes)) 1664 .int JMPTBL (L(36bytes), L(table_64bytes)) 1665 .int JMPTBL (L(37bytes), L(table_64bytes)) 1666 .int JMPTBL (L(38bytes), L(table_64bytes)) 1667 .int JMPTBL (L(39bytes), L(table_64bytes)) 1668 .int JMPTBL (L(40bytes), L(table_64bytes)) 1669 .int JMPTBL (L(41bytes), L(table_64bytes)) 1670 .int JMPTBL (L(42bytes), L(table_64bytes)) 1671 .int JMPTBL (L(43bytes), L(table_64bytes)) 1672 .int JMPTBL (L(44bytes), L(table_64bytes)) 1673 .int JMPTBL (L(45bytes), L(table_64bytes)) 1674 .int JMPTBL (L(46bytes), L(table_64bytes)) 1675 .int JMPTBL (L(47bytes), L(table_64bytes)) 1676 .int JMPTBL (L(48bytes), L(table_64bytes)) 1677 .int JMPTBL (L(49bytes), L(table_64bytes)) 1678 .int JMPTBL (L(50bytes), L(table_64bytes)) 1679 .int JMPTBL (L(51bytes), L(table_64bytes)) 1680 .int JMPTBL (L(52bytes), L(table_64bytes)) 1681 .int JMPTBL (L(53bytes), L(table_64bytes)) 1682 .int JMPTBL (L(54bytes), L(table_64bytes)) 1683 .int JMPTBL (L(55bytes), L(table_64bytes)) 1684 .int JMPTBL (L(56bytes), L(table_64bytes)) 1685 .int JMPTBL (L(57bytes), L(table_64bytes)) 1686 .int JMPTBL (L(58bytes), L(table_64bytes)) 1687 .int JMPTBL (L(59bytes), L(table_64bytes)) 1688 .int JMPTBL (L(60bytes), L(table_64bytes)) 1689 .int JMPTBL (L(61bytes), L(table_64bytes)) 1690 .int JMPTBL (L(62bytes), L(table_64bytes)) 1691 .int JMPTBL (L(63bytes), L(table_64bytes)) 1692 .int JMPTBL (L(64bytes), L(table_64bytes)) 1693 .int JMPTBL (L(65bytes), L(table_64bytes)) 1694 .int JMPTBL (L(66bytes), L(table_64bytes)) 1695 .int JMPTBL (L(67bytes), L(table_64bytes)) 1696 .int JMPTBL (L(68bytes), L(table_64bytes)) 1697 .int JMPTBL (L(69bytes), L(table_64bytes)) 1698 .int JMPTBL (L(70bytes), L(table_64bytes)) 1699 .int JMPTBL (L(71bytes), L(table_64bytes)) 1700 .int JMPTBL (L(72bytes), L(table_64bytes)) 1701 .int JMPTBL (L(73bytes), L(table_64bytes)) 1702 .int JMPTBL (L(74bytes), L(table_64bytes)) 1703 .int JMPTBL (L(75bytes), L(table_64bytes)) 1704 .int JMPTBL (L(76bytes), L(table_64bytes)) 1705 .int JMPTBL (L(77bytes), L(table_64bytes)) 1706 .int JMPTBL (L(78bytes), L(table_64bytes)) 1707 .int JMPTBL (L(79bytes), L(table_64bytes)) 1708#else 1709L(table_64bytes): 1710 .int JMPTBL (L(0bytes), L(table_64bytes)) 1711 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1712 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1713 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1714 .int JMPTBL (L(4bytes), L(table_64bytes)) 1715 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1716 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1717 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1718 .int JMPTBL (L(8bytes), L(table_64bytes)) 1719 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1720 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1721 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1722 .int JMPTBL (L(12bytes), L(table_64bytes)) 1723 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1724 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1725 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1726 .int JMPTBL (L(16bytes), L(table_64bytes)) 1727 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1728 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1729 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1730 .int JMPTBL (L(20bytes), L(table_64bytes)) 1731 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1732 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1733 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1734 .int JMPTBL (L(24bytes), L(table_64bytes)) 1735 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1736 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1737 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1738 .int JMPTBL (L(28bytes), L(table_64bytes)) 1739 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1740 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1741 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1742 .int JMPTBL (L(32bytes), L(table_64bytes)) 1743 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1744 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1745 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1746 .int JMPTBL (L(36bytes), L(table_64bytes)) 1747 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1748 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1749 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1750 .int JMPTBL (L(40bytes), L(table_64bytes)) 1751 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1752 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1753 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1754 .int JMPTBL (L(44bytes), L(table_64bytes)) 1755 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1756 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1757 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1758 .int JMPTBL (L(48bytes), L(table_64bytes)) 1759 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1760 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1761 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1762 .int JMPTBL (L(52bytes), L(table_64bytes)) 1763 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1764 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1765 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1766 .int JMPTBL (L(56bytes), L(table_64bytes)) 1767 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1768 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1769 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1770 .int JMPTBL (L(60bytes), L(table_64bytes)) 1771 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1772 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1773 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1774 .int JMPTBL (L(64bytes), L(table_64bytes)) 1775 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1776 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1777 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1778 .int JMPTBL (L(68bytes), L(table_64bytes)) 1779 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1780 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1781 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1782 .int JMPTBL (L(72bytes), L(table_64bytes)) 1783 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1784 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1785 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1786 .int JMPTBL (L(76bytes), L(table_64bytes)) 1787 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1788 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1789 .int JMPTBL (L(unreal_case), L(table_64bytes)) 1790#endif 1791