2 Copyright (C) 2010 Free Software Foundation, Inc.
3 Contributed by Intel Corporation.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
24 #include "asm-syntax.h"
27 # define MEMCMP __memcmp_sse4_1
31 # define ALIGN(n) .p2align n
34 #define JMPTBL(I, B) (I - B)
36 #define BRANCH_TO_JMPTBL_ENTRY(TABLE, INDEX, SCALE) \
37 lea TABLE(%rip), %r11; \
38 movslq (%r11, INDEX, SCALE), %rcx; \
43 .section .text.sse4.1,"ax",@progbits
52 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
88 movdqu 16(%rdi), %xmm2
93 movdqu 32(%rdi), %xmm2
98 movdqu 48(%rdi), %xmm2
103 jb L(less32bytesin64)
105 movdqu 64(%rdi), %xmm2
110 movdqu 80(%rdi), %xmm2
122 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
137 movdqu 16(%rdi), %xmm2
142 movdqu 32(%rdi), %xmm2
147 movdqu 48(%rdi), %xmm2
152 movdqu 64(%rdi), %xmm2
157 movdqu 80(%rdi), %xmm2
162 movdqu 96(%rdi), %xmm2
167 movdqu 112(%rdi), %xmm2
168 pxor 112(%rsi), %xmm2
179 jb L(less32bytesin128)
186 movdqu 16(%rdi), %xmm2
196 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
205 movdqu 16(%rdi), %xmm2
210 movdqu 32(%rdi), %xmm2
215 movdqu 48(%rdi), %xmm2
220 movdqu 64(%rdi), %xmm2
225 movdqu 80(%rdi), %xmm2
230 movdqu 96(%rdi), %xmm2
235 movdqu 112(%rdi), %xmm2
236 pxor 112(%rsi), %xmm2
240 movdqu 128(%rdi), %xmm2
241 pxor 128(%rsi), %xmm2
245 movdqu 144(%rdi), %xmm2
246 pxor 144(%rsi), %xmm2
250 movdqu 160(%rdi), %xmm2
251 pxor 160(%rsi), %xmm2
255 movdqu 176(%rdi), %xmm2
256 pxor 176(%rsi), %xmm2
260 movdqu 192(%rdi), %xmm2
261 pxor 192(%rsi), %xmm2
265 movdqu 208(%rdi), %xmm2
266 pxor 208(%rsi), %xmm2
270 movdqu 224(%rdi), %xmm2
271 pxor 224(%rsi), %xmm2
275 movdqu 240(%rdi), %xmm2
276 pxor 240(%rsi), %xmm2
290 jb L(less32bytesin256)
297 movdqu 16(%rdi), %xmm2
307 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
311 #ifdef DATA_CACHE_SIZE_HALF
312 mov $DATA_CACHE_SIZE_HALF, %r8
314 mov __x86_64_data_cache_size_half(%rip), %r8
320 ja L(L2_L3_cache_unaglined)
323 L(64bytesormore_loop):
328 movdqu 16(%rdi), %xmm3
332 movdqu 32(%rdi), %xmm4
336 movdqu 48(%rdi), %xmm5
341 jnc L(64bytesormore_loop_end)
345 jae L(64bytesormore_loop)
350 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
352 L(L2_L3_cache_unaglined):
355 L(L2_L3_unaligned_128bytes_loop):
356 prefetchnta 0x1c0(%rdi)
357 prefetchnta 0x1c0(%rsi)
362 movdqu 16(%rdi), %xmm3
366 movdqu 32(%rdi), %xmm4
370 movdqu 48(%rdi), %xmm5
375 jnc L(64bytesormore_loop_end)
379 jae L(L2_L3_unaligned_128bytes_loop)
384 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
387 * This case is for machines which are sensitive for unaligned instructions.
392 ja L(128bytesormorein2aligned)
393 L(less128bytesin2aligned):
401 movdqa 16(%rdi), %xmm2
406 movdqa 32(%rdi), %xmm2
411 movdqa 48(%rdi), %xmm2
416 jb L(less32bytesin64in2alinged)
418 movdqa 64(%rdi), %xmm2
423 movdqa 80(%rdi), %xmm2
430 L(less32bytesin64in2alinged):
435 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
438 L(128bytesormorein2aligned):
440 ja L(512bytesormorein2aligned)
442 ja L(256bytesormorein2aligned)
443 L(less256bytesin2alinged):
451 movdqa 16(%rdi), %xmm2
456 movdqa 32(%rdi), %xmm2
461 movdqa 48(%rdi), %xmm2
466 movdqa 64(%rdi), %xmm2
471 movdqa 80(%rdi), %xmm2
476 movdqa 96(%rdi), %xmm2
481 movdqa 112(%rdi), %xmm2
482 pxor 112(%rsi), %xmm2
490 jae L(less128bytesin2aligned)
493 jb L(less32bytesin128in2aligned)
500 movdqu 16(%rdi), %xmm2
507 L(less32bytesin128in2aligned):
510 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
513 L(256bytesormorein2aligned):
521 movdqa 16(%rdi), %xmm2
526 movdqa 32(%rdi), %xmm2
531 movdqa 48(%rdi), %xmm2
536 movdqa 64(%rdi), %xmm2
541 movdqa 80(%rdi), %xmm2
546 movdqa 96(%rdi), %xmm2
551 movdqa 112(%rdi), %xmm2
552 pxor 112(%rsi), %xmm2
556 movdqa 128(%rdi), %xmm2
557 pxor 128(%rsi), %xmm2
561 movdqa 144(%rdi), %xmm2
562 pxor 144(%rsi), %xmm2
566 movdqa 160(%rdi), %xmm2
567 pxor 160(%rsi), %xmm2
571 movdqa 176(%rdi), %xmm2
572 pxor 176(%rsi), %xmm2
576 movdqa 192(%rdi), %xmm2
577 pxor 192(%rsi), %xmm2
581 movdqa 208(%rdi), %xmm2
582 pxor 208(%rsi), %xmm2
586 movdqa 224(%rdi), %xmm2
587 pxor 224(%rsi), %xmm2
591 movdqa 240(%rdi), %xmm2
592 pxor 240(%rsi), %xmm2
600 jae L(less256bytesin2alinged)
603 jae L(less128bytesin2aligned)
606 jb L(less32bytesin256in2alinged)
613 movdqa 16(%rdi), %xmm2
620 L(less32bytesin256in2alinged):
623 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
626 L(512bytesormorein2aligned):
627 #ifdef SHARED_CACHE_SIZE_HALF
628 mov $DATA_CACHE_SIZE_HALF, %r8
630 mov __x86_64_data_cache_size_half(%rip), %r8
636 ja L(L2_L3_cache_aglined)
640 L(64bytesormore_loopin2aligned):
645 movdqa 16(%rdi), %xmm3
649 movdqa 32(%rdi), %xmm4
653 movdqa 48(%rdi), %xmm5
658 jnc L(64bytesormore_loop_end)
662 jae L(64bytesormore_loopin2aligned)
667 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
668 L(L2_L3_cache_aglined):
671 L(L2_L3_aligned_128bytes_loop):
672 prefetchnta 0x1c0(%rdi)
673 prefetchnta 0x1c0(%rsi)
678 movdqa 16(%rdi), %xmm3
682 movdqa 32(%rdi), %xmm4
686 movdqa 48(%rdi), %xmm5
691 jnc L(64bytesormore_loop_end)
695 jae L(L2_L3_aligned_128bytes_loop)
700 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
704 L(64bytesormore_loop_end):
815 movdqu -65(%rdi), %xmm1
816 movdqu -65(%rsi), %xmm2
822 movdqu -49(%rdi), %xmm1
823 movdqu -49(%rsi), %xmm2
829 movdqu -33(%rdi), %xmm1
830 movdqu -33(%rsi), %xmm2
845 movzbl -1(%rdi), %eax
846 movzbl -1(%rsi), %edx
869 movzbl -1(%rdi), %eax
870 movzbl -1(%rsi), %edx
876 movdqu -66(%rdi), %xmm1
877 movdqu -66(%rsi), %xmm2
883 movdqu -50(%rdi), %xmm1
884 movdqu -50(%rsi), %xmm2
890 movdqu -34(%rdi), %xmm1
891 movdqu -34(%rsi), %xmm2
906 movzwl -2(%rdi), %eax
907 movzwl -2(%rsi), %ecx
935 movzwl -2(%rsi), %ecx
936 movzwl -2(%rdi), %eax
946 movdqu -67(%rdi), %xmm2
947 movdqu -67(%rsi), %xmm1
953 movdqu -51(%rdi), %xmm2
954 movdqu -51(%rsi), %xmm1
960 movdqu -35(%rsi), %xmm1
961 movdqu -35(%rdi), %xmm2
1011 movzwl -3(%rdi), %eax
1012 movzwl -3(%rsi), %ecx
1016 movzbl -1(%rdi), %eax
1017 movzbl -1(%rsi), %ecx
1023 movdqu -68(%rdi), %xmm2
1024 movdqu -68(%rsi), %xmm1
1030 movdqu -52(%rdi), %xmm2
1031 movdqu -52(%rsi), %xmm1
1037 movdqu -36(%rdi), %xmm2
1038 movdqu -36(%rsi), %xmm1
1044 movdqu -20(%rdi), %xmm2
1045 movdqu -20(%rsi), %xmm1
1059 movdqu -69(%rsi), %xmm1
1060 movdqu -69(%rdi), %xmm2
1066 movdqu -53(%rsi), %xmm1
1067 movdqu -53(%rdi), %xmm2
1073 movdqu -37(%rsi), %xmm1
1074 movdqu -37(%rdi), %xmm2
1080 movdqu -21(%rsi), %xmm1
1081 movdqu -21(%rdi), %xmm2
1095 movdqu -70(%rsi), %xmm1
1096 movdqu -70(%rdi), %xmm2
1102 movdqu -54(%rsi), %xmm1
1103 movdqu -54(%rdi), %xmm2
1109 movdqu -38(%rsi), %xmm1
1110 movdqu -38(%rdi), %xmm2
1116 movdqu -22(%rsi), %xmm1
1117 movdqu -22(%rdi), %xmm2
1131 movdqu -71(%rsi), %xmm1
1132 movdqu -71(%rdi), %xmm2
1138 movdqu -55(%rdi), %xmm2
1139 movdqu -55(%rsi), %xmm1
1145 movdqu -39(%rdi), %xmm2
1146 movdqu -39(%rsi), %xmm1
1152 movdqu -23(%rdi), %xmm2
1153 movdqu -23(%rsi), %xmm1
1167 movdqu -72(%rsi), %xmm1
1168 movdqu -72(%rdi), %xmm2
1174 movdqu -56(%rdi), %xmm2
1175 movdqu -56(%rsi), %xmm1
1181 movdqu -40(%rdi), %xmm2
1182 movdqu -40(%rsi), %xmm1
1188 movdqu -24(%rdi), %xmm2
1189 movdqu -24(%rsi), %xmm1
1203 movdqu -73(%rsi), %xmm1
1204 movdqu -73(%rdi), %xmm2
1210 movdqu -57(%rdi), %xmm2
1211 movdqu -57(%rsi), %xmm1
1217 movdqu -41(%rdi), %xmm2
1218 movdqu -41(%rsi), %xmm1
1224 movdqu -25(%rdi), %xmm2
1225 movdqu -25(%rsi), %xmm1
1234 movzbl -1(%rdi), %eax
1235 movzbl -1(%rsi), %ecx
1241 movdqu -74(%rsi), %xmm1
1242 movdqu -74(%rdi), %xmm2
1248 movdqu -58(%rdi), %xmm2
1249 movdqu -58(%rsi), %xmm1
1255 movdqu -42(%rdi), %xmm2
1256 movdqu -42(%rsi), %xmm1
1262 movdqu -26(%rdi), %xmm2
1263 movdqu -26(%rsi), %xmm1
1272 movzwl -2(%rdi), %eax
1273 movzwl -2(%rsi), %ecx
1278 movdqu -75(%rsi), %xmm1
1279 movdqu -75(%rdi), %xmm2
1285 movdqu -59(%rdi), %xmm2
1286 movdqu -59(%rsi), %xmm1
1292 movdqu -43(%rdi), %xmm2
1293 movdqu -43(%rsi), %xmm1
1299 movdqu -27(%rdi), %xmm2
1300 movdqu -27(%rsi), %xmm1
1318 movdqu -76(%rsi), %xmm1
1319 movdqu -76(%rdi), %xmm2
1325 movdqu -60(%rdi), %xmm2
1326 movdqu -60(%rsi), %xmm1
1332 movdqu -44(%rdi), %xmm2
1333 movdqu -44(%rsi), %xmm1
1339 movdqu -28(%rdi), %xmm2
1340 movdqu -28(%rsi), %xmm1
1358 movdqu -77(%rsi), %xmm1
1359 movdqu -77(%rdi), %xmm2
1365 movdqu -61(%rdi), %xmm2
1366 movdqu -61(%rsi), %xmm1
1372 movdqu -45(%rdi), %xmm2
1373 movdqu -45(%rsi), %xmm1
1379 movdqu -29(%rdi), %xmm2
1380 movdqu -29(%rsi), %xmm1
1400 movdqu -78(%rsi), %xmm1
1401 movdqu -78(%rdi), %xmm2
1407 movdqu -62(%rdi), %xmm2
1408 movdqu -62(%rsi), %xmm1
1414 movdqu -46(%rdi), %xmm2
1415 movdqu -46(%rsi), %xmm1
1421 movdqu -30(%rdi), %xmm2
1422 movdqu -30(%rsi), %xmm1
1440 movdqu -79(%rsi), %xmm1
1441 movdqu -79(%rdi), %xmm2
1447 movdqu -63(%rdi), %xmm2
1448 movdqu -63(%rsi), %xmm1
1454 movdqu -47(%rdi), %xmm2
1455 movdqu -47(%rsi), %xmm1
1461 movdqu -31(%rdi), %xmm2
1462 movdqu -31(%rsi), %xmm1
1480 movdqu -64(%rdi), %xmm2
1481 movdqu -64(%rsi), %xmm1
1487 movdqu -48(%rdi), %xmm2
1488 movdqu -48(%rsi), %xmm1
1494 movdqu -32(%rdi), %xmm2
1495 movdqu -32(%rsi), %xmm1
1514 * Aligned 8 bytes to avoid 2 branch "taken" in one 16 alinged code block.
1519 mov (%rsi, %rdx), %rcx
1520 mov (%rdi, %rdx), %rax
1523 mov 8(%rsi, %rdx), %rcx
1524 mov 8(%rdi, %rdx), %rax
1552 .section .rodata.sse4.1,"a",@progbits
1555 .int JMPTBL (L(0bytes), L(table_64bytes))
1556 .int JMPTBL (L(1bytes), L(table_64bytes))
1557 .int JMPTBL (L(2bytes), L(table_64bytes))
1558 .int JMPTBL (L(3bytes), L(table_64bytes))
1559 .int JMPTBL (L(4bytes), L(table_64bytes))
1560 .int JMPTBL (L(5bytes), L(table_64bytes))
1561 .int JMPTBL (L(6bytes), L(table_64bytes))
1562 .int JMPTBL (L(7bytes), L(table_64bytes))
1563 .int JMPTBL (L(8bytes), L(table_64bytes))
1564 .int JMPTBL (L(9bytes), L(table_64bytes))
1565 .int JMPTBL (L(10bytes), L(table_64bytes))
1566 .int JMPTBL (L(11bytes), L(table_64bytes))
1567 .int JMPTBL (L(12bytes), L(table_64bytes))
1568 .int JMPTBL (L(13bytes), L(table_64bytes))
1569 .int JMPTBL (L(14bytes), L(table_64bytes))
1570 .int JMPTBL (L(15bytes), L(table_64bytes))
1571 .int JMPTBL (L(16bytes), L(table_64bytes))
1572 .int JMPTBL (L(17bytes), L(table_64bytes))
1573 .int JMPTBL (L(18bytes), L(table_64bytes))
1574 .int JMPTBL (L(19bytes), L(table_64bytes))
1575 .int JMPTBL (L(20bytes), L(table_64bytes))
1576 .int JMPTBL (L(21bytes), L(table_64bytes))
1577 .int JMPTBL (L(22bytes), L(table_64bytes))
1578 .int JMPTBL (L(23bytes), L(table_64bytes))
1579 .int JMPTBL (L(24bytes), L(table_64bytes))
1580 .int JMPTBL (L(25bytes), L(table_64bytes))
1581 .int JMPTBL (L(26bytes), L(table_64bytes))
1582 .int JMPTBL (L(27bytes), L(table_64bytes))
1583 .int JMPTBL (L(28bytes), L(table_64bytes))
1584 .int JMPTBL (L(29bytes), L(table_64bytes))
1585 .int JMPTBL (L(30bytes), L(table_64bytes))
1586 .int JMPTBL (L(31bytes), L(table_64bytes))
1587 .int JMPTBL (L(32bytes), L(table_64bytes))
1588 .int JMPTBL (L(33bytes), L(table_64bytes))
1589 .int JMPTBL (L(34bytes), L(table_64bytes))
1590 .int JMPTBL (L(35bytes), L(table_64bytes))
1591 .int JMPTBL (L(36bytes), L(table_64bytes))
1592 .int JMPTBL (L(37bytes), L(table_64bytes))
1593 .int JMPTBL (L(38bytes), L(table_64bytes))
1594 .int JMPTBL (L(39bytes), L(table_64bytes))
1595 .int JMPTBL (L(40bytes), L(table_64bytes))
1596 .int JMPTBL (L(41bytes), L(table_64bytes))
1597 .int JMPTBL (L(42bytes), L(table_64bytes))
1598 .int JMPTBL (L(43bytes), L(table_64bytes))
1599 .int JMPTBL (L(44bytes), L(table_64bytes))
1600 .int JMPTBL (L(45bytes), L(table_64bytes))
1601 .int JMPTBL (L(46bytes), L(table_64bytes))
1602 .int JMPTBL (L(47bytes), L(table_64bytes))
1603 .int JMPTBL (L(48bytes), L(table_64bytes))
1604 .int JMPTBL (L(49bytes), L(table_64bytes))
1605 .int JMPTBL (L(50bytes), L(table_64bytes))
1606 .int JMPTBL (L(51bytes), L(table_64bytes))
1607 .int JMPTBL (L(52bytes), L(table_64bytes))
1608 .int JMPTBL (L(53bytes), L(table_64bytes))
1609 .int JMPTBL (L(54bytes), L(table_64bytes))
1610 .int JMPTBL (L(55bytes), L(table_64bytes))
1611 .int JMPTBL (L(56bytes), L(table_64bytes))
1612 .int JMPTBL (L(57bytes), L(table_64bytes))
1613 .int JMPTBL (L(58bytes), L(table_64bytes))
1614 .int JMPTBL (L(59bytes), L(table_64bytes))
1615 .int JMPTBL (L(60bytes), L(table_64bytes))
1616 .int JMPTBL (L(61bytes), L(table_64bytes))
1617 .int JMPTBL (L(62bytes), L(table_64bytes))
1618 .int JMPTBL (L(63bytes), L(table_64bytes))
1619 .int JMPTBL (L(64bytes), L(table_64bytes))
1620 .int JMPTBL (L(65bytes), L(table_64bytes))
1621 .int JMPTBL (L(66bytes), L(table_64bytes))
1622 .int JMPTBL (L(67bytes), L(table_64bytes))
1623 .int JMPTBL (L(68bytes), L(table_64bytes))
1624 .int JMPTBL (L(69bytes), L(table_64bytes))
1625 .int JMPTBL (L(70bytes), L(table_64bytes))
1626 .int JMPTBL (L(71bytes), L(table_64bytes))
1627 .int JMPTBL (L(72bytes), L(table_64bytes))
1628 .int JMPTBL (L(73bytes), L(table_64bytes))
1629 .int JMPTBL (L(74bytes), L(table_64bytes))
1630 .int JMPTBL (L(75bytes), L(table_64bytes))
1631 .int JMPTBL (L(76bytes), L(table_64bytes))
1632 .int JMPTBL (L(77bytes), L(table_64bytes))
1633 .int JMPTBL (L(78bytes), L(table_64bytes))
1634 .int JMPTBL (L(79bytes), L(table_64bytes))