aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/i386/i686/multiarch/memcmp-sse4.S
blob: 2984a374cfa5e4c95ab70c5ea77f85f2d48c87d4 (plain)
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
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
/* memcmp with SSE4.2, wmemcmp with SSE4.2
   Copyright (C) 2010-2013 Free Software Foundation, Inc.
   Contributed by Intel Corporation.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, see
   <http://www.gnu.org/licenses/>.  */

#ifndef NOT_IN_libc

# include <sysdep.h>

# ifndef MEMCMP
#  define MEMCMP	__memcmp_sse4_2
# endif

# define CFI_PUSH(REG)	\
	cfi_adjust_cfa_offset (4);	\
	cfi_rel_offset (REG, 0)

# define CFI_POP(REG)	\
	cfi_adjust_cfa_offset (-4);	\
	cfi_restore (REG)

# define PUSH(REG)	pushl REG; CFI_PUSH (REG)
# define POP(REG)	popl REG; CFI_POP (REG)

# define PARMS	4
# define BLK1	PARMS
# define BLK2	BLK1 + 4
# define LEN	BLK2 + 4
# define RETURN	POP (%ebx); ret; CFI_PUSH (%ebx)


# ifdef SHARED
#  define JMPTBL(I, B)	I - B

/* Load an entry in a jump table into EBX and branch to it.  TABLE is a
	jump	table with relative offsets.  INDEX is a register contains the
	index	into the jump table.   SCALE is the scale of INDEX. */

#  define BRANCH_TO_JMPTBL_ENTRY(TABLE, INDEX, SCALE)	\
/* We first load PC into EBX.  */	\
	SETUP_PIC_REG(bx);	\
/* Get the address of the jump table.  */	\
	addl	$(TABLE - .), %ebx;	\
/* Get the entry and convert the relative offset to the	\
	absolute	address.  */	\
	addl	(%ebx,INDEX,SCALE), %ebx;	\
/* We loaded the jump table and adjusted EDX/ESI. Go.  */	\
	jmp	*%ebx
# else
#  define JMPTBL(I, B)	I

/* Load an entry in a jump table into EBX and branch to it.  TABLE is a
	jump	table with relative offsets.  INDEX is a register contains the
	index	into the jump table.   SCALE is the scale of INDEX. */
#  define BRANCH_TO_JMPTBL_ENTRY(TABLE, INDEX, SCALE)	\
	jmp	*TABLE(,INDEX,SCALE)
# endif


/* Warning!
           wmemcmp has to use SIGNED comparison for elements.
           memcmp has to use UNSIGNED comparison for elemnts.
*/

	.section .text.sse4.2,"ax",@progbits
ENTRY (MEMCMP)
	movl	BLK1(%esp), %eax
	movl	BLK2(%esp), %edx
	movl	LEN(%esp), %ecx

# ifdef USE_AS_WMEMCMP
	shl	$2, %ecx
	test	%ecx, %ecx
	jz	L(return0)
# else
	cmp	$1, %ecx
	jbe	L(less1bytes)
# endif

	pxor	%xmm0, %xmm0
	cmp	$64, %ecx
	ja	L(64bytesormore)
	cmp	$8, %ecx

# ifndef USE_AS_WMEMCMP
	PUSH	(%ebx)
	jb	L(less8bytes)
# else
	jb	L(less8bytes)
	PUSH	(%ebx)
# endif

	add	%ecx, %edx
	add	%ecx, %eax
	BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %ecx, 4)

# ifndef USE_AS_WMEMCMP
	.p2align 4
L(less8bytes):
	mov	(%eax), %bl
	cmpb	(%edx), %bl
	jne	L(nonzero)

	mov	1(%eax), %bl
	cmpb	1(%edx), %bl
	jne	L(nonzero)

	cmp	$2, %ecx
	jz	L(0bytes)

	mov	2(%eax), %bl
	cmpb	2(%edx), %bl
	jne	L(nonzero)

	cmp	$3, %ecx
	jz	L(0bytes)

	mov	3(%eax), %bl
	cmpb	3(%edx), %bl
	jne	L(nonzero)

	cmp	$4, %ecx
	jz	L(0bytes)

	mov	4(%eax), %bl
	cmpb	4(%edx), %bl
	jne	L(nonzero)

	cmp	$5, %ecx
	jz	L(0bytes)

	mov	5(%eax), %bl
	cmpb	5(%edx), %bl
	jne	L(nonzero)

	cmp	$6, %ecx
	jz	L(0bytes)

	mov	6(%eax), %bl
	cmpb	6(%edx), %bl
	je	L(0bytes)

L(nonzero):
	POP	(%ebx)
	mov	$1, %eax
	ja	L(above)
	neg	%eax
L(above):
	ret
	CFI_PUSH (%ebx)
# endif

	.p2align 4
L(0bytes):
	POP	(%ebx)
	xor	%eax, %eax
	ret

# ifdef USE_AS_WMEMCMP

/* for wmemcmp, case N == 1 */

	.p2align 4
L(less8bytes):
	mov	(%eax), %ecx
	cmp	(%edx), %ecx
	je	L(return0)
	mov	$1, %eax
	jg	L(find_diff_bigger)
	neg	%eax
	ret

	.p2align 4
L(find_diff_bigger):
	ret

	.p2align 4
L(return0):
	xor	%eax, %eax
	ret
# endif

# ifndef USE_AS_WMEMCMP
	.p2align 4
L(less1bytes):
	jb	L(0bytesend)
	movzbl	(%eax), %eax
	movzbl	(%edx), %edx
	sub	%edx, %eax
	ret

	.p2align 4
L(0bytesend):
	xor	%eax, %eax
	ret
# endif
	.p2align 4
L(64bytesormore):
	PUSH	(%ebx)
	mov	%ecx, %ebx
	mov	$64, %ecx
	sub	$64, %ebx
L(64bytesormore_loop):
	movdqu	(%eax), %xmm1
	movdqu	(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(find_16diff)

	movdqu	16(%eax), %xmm1
	movdqu	16(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(find_32diff)

	movdqu	32(%eax), %xmm1
	movdqu	32(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(find_48diff)

	movdqu	48(%eax), %xmm1
	movdqu	48(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(find_64diff)
	add	%ecx, %eax
	add	%ecx, %edx
	sub	%ecx, %ebx
	jae	L(64bytesormore_loop)
	add	%ebx, %ecx
	add	%ecx, %edx
	add	%ecx, %eax
	BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %ecx, 4)

# ifdef USE_AS_WMEMCMP

/* Label needs only for table_64bytes filling */
L(unreal_case):
/* no code here */

# endif
	.p2align 4
L(find_16diff):
	sub	$16, %ecx
L(find_32diff):
	sub	$16, %ecx
L(find_48diff):
	sub	$16, %ecx
L(find_64diff):
	add	%ecx, %edx
	add	%ecx, %eax

# ifndef USE_AS_WMEMCMP
	.p2align 4
L(16bytes):
	mov	-16(%eax), %ecx
	mov	-16(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
L(12bytes):
	mov	-12(%eax), %ecx
	mov	-12(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
L(8bytes):
	mov	-8(%eax), %ecx
	mov	-8(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
L(4bytes):
	mov	-4(%eax), %ecx
	mov	-4(%edx), %ebx
	cmp	%ebx, %ecx
	mov	$0, %eax
	jne	L(find_diff)
	RETURN
# else
	.p2align 4
L(16bytes):
	mov	-16(%eax), %ecx
	cmp	-16(%edx), %ecx
	jne	L(find_diff)
L(12bytes):
	mov	-12(%eax), %ecx
	cmp	-12(%edx), %ecx
	jne	L(find_diff)
L(8bytes):
	mov	-8(%eax), %ecx
	cmp	-8(%edx), %ecx
	jne	L(find_diff)
L(4bytes):
	mov	-4(%eax), %ecx
	cmp	-4(%edx), %ecx
	mov	$0, %eax
	jne	L(find_diff)
	RETURN
# endif

# ifndef USE_AS_WMEMCMP
	.p2align 4
L(49bytes):
	movdqu	-49(%eax), %xmm1
	movdqu	-49(%edx), %xmm2
	mov	$-49, %ebx
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(33bytes):
	movdqu	-33(%eax), %xmm1
	movdqu	-33(%edx), %xmm2
	mov	$-33, %ebx
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(17bytes):
	mov	-17(%eax), %ecx
	mov	-17(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
L(13bytes):
	mov	-13(%eax), %ecx
	mov	-13(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
L(9bytes):
	mov	-9(%eax), %ecx
	mov	-9(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
L(5bytes):
	mov	-5(%eax), %ecx
	mov	-5(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
	movzbl	-1(%eax), %ecx
	cmp	-1(%edx), %cl
	mov	$0, %eax
	jne	L(end)
	RETURN

	.p2align 4
L(50bytes):
	mov	$-50, %ebx
	movdqu	-50(%eax), %xmm1
	movdqu	-50(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(34bytes):
	mov	$-34, %ebx
	movdqu	-34(%eax), %xmm1
	movdqu	-34(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(18bytes):
	mov	-18(%eax), %ecx
	mov	-18(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
L(14bytes):
	mov	-14(%eax), %ecx
	mov	-14(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
L(10bytes):
	mov	-10(%eax), %ecx
	mov	-10(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
L(6bytes):
	mov	-6(%eax), %ecx
	mov	-6(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
L(2bytes):
	movzwl	-2(%eax), %ecx
	movzwl	-2(%edx), %ebx
	cmp	%bl, %cl
	jne	L(end)
	cmp	%bh, %ch
	mov	$0, %eax
	jne	L(end)
	RETURN

	.p2align 4
L(51bytes):
	mov	$-51, %ebx
	movdqu	-51(%eax), %xmm1
	movdqu	-51(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(35bytes):
	mov	$-35, %ebx
	movdqu	-35(%eax), %xmm1
	movdqu	-35(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(19bytes):
	movl	-19(%eax), %ecx
	movl	-19(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
L(15bytes):
	movl	-15(%eax), %ecx
	movl	-15(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
L(11bytes):
	movl	-11(%eax), %ecx
	movl	-11(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
L(7bytes):
	movl	-7(%eax), %ecx
	movl	-7(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
L(3bytes):
	movzwl	-3(%eax), %ecx
	movzwl	-3(%edx), %ebx
	cmpb	%bl, %cl
	jne	L(end)
	cmp	%bx, %cx
	jne	L(end)
L(1bytes):
	movzbl	-1(%eax), %eax
	cmpb	-1(%edx), %al
	mov	$0, %eax
	jne	L(end)
	RETURN
# endif
	.p2align 4
L(52bytes):
	movdqu	-52(%eax), %xmm1
	movdqu	-52(%edx), %xmm2
	mov	$-52, %ebx
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(36bytes):
	movdqu	-36(%eax), %xmm1
	movdqu	-36(%edx), %xmm2
	mov	$-36, %ebx
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(20bytes):
	movdqu	-20(%eax), %xmm1
	movdqu	-20(%edx), %xmm2
	mov	$-20, %ebx
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
	mov	-4(%eax), %ecx
# ifndef USE_AS_WMEMCMP
	mov	-4(%edx), %ebx
	cmp	%ebx, %ecx
# else
	cmp	-4(%edx), %ecx
# endif
	mov	$0, %eax
	jne	L(find_diff)
	RETURN

# ifndef USE_AS_WMEMCMP
	.p2align 4
L(53bytes):
	movdqu	-53(%eax), %xmm1
	movdqu	-53(%edx), %xmm2
	mov	$-53, %ebx
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(37bytes):
	mov	$-37, %ebx
	movdqu	-37(%eax), %xmm1
	movdqu	-37(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(21bytes):
	mov	$-21, %ebx
	movdqu	-21(%eax), %xmm1
	movdqu	-21(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
	mov	-5(%eax), %ecx
	mov	-5(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
	movzbl	-1(%eax), %ecx
	cmp	-1(%edx), %cl
	mov	$0, %eax
	jne	L(end)
	RETURN

	.p2align 4
L(54bytes):
	movdqu	-54(%eax), %xmm1
	movdqu	-54(%edx), %xmm2
	mov	$-54, %ebx
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(38bytes):
	mov	$-38, %ebx
	movdqu	-38(%eax), %xmm1
	movdqu	-38(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(22bytes):
	mov	$-22, %ebx
	movdqu	-22(%eax), %xmm1
	movdqu	-22(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)

	mov	-6(%eax), %ecx
	mov	-6(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
	movzwl	-2(%eax), %ecx
	movzwl	-2(%edx), %ebx
	cmp	%bl, %cl
	jne	L(end)
	cmp	%bh, %ch
	mov	$0, %eax
	jne	L(end)
	RETURN

	.p2align 4
L(55bytes):
	movdqu	-55(%eax), %xmm1
	movdqu	-55(%edx), %xmm2
	mov	$-55, %ebx
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(39bytes):
	mov	$-39, %ebx
	movdqu	-39(%eax), %xmm1
	movdqu	-39(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(23bytes):
	mov	$-23, %ebx
	movdqu	-23(%eax), %xmm1
	movdqu	-23(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
	movl	-7(%eax), %ecx
	movl	-7(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
	movzwl	-3(%eax), %ecx
	movzwl	-3(%edx), %ebx
	cmpb	%bl, %cl
	jne	L(end)
	cmp	%bx, %cx
	jne	L(end)
	movzbl	-1(%eax), %eax
	cmpb	-1(%edx), %al
	mov	$0, %eax
	jne	L(end)
	RETURN
# endif
	.p2align 4
L(56bytes):
	movdqu	-56(%eax), %xmm1
	movdqu	-56(%edx), %xmm2
	mov	$-56, %ebx
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(40bytes):
	mov	$-40, %ebx
	movdqu	-40(%eax), %xmm1
	movdqu	-40(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(24bytes):
	mov	$-24, %ebx
	movdqu	-24(%eax), %xmm1
	movdqu	-24(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)

	mov	-8(%eax), %ecx
# ifndef USE_AS_WMEMCMP
	mov	-8(%edx), %ebx
	cmp	%ebx, %ecx
# else
	cmp	-8(%edx), %ecx
# endif
	jne	L(find_diff)

	mov	-4(%eax), %ecx
# ifndef USE_AS_WMEMCMP
	mov	-4(%edx), %ebx
	cmp	%ebx, %ecx
# else
	cmp	-4(%edx), %ecx
# endif
	mov	$0, %eax
	jne	L(find_diff)
	RETURN

# ifndef USE_AS_WMEMCMP
	.p2align 4
L(57bytes):
	movdqu	-57(%eax), %xmm1
	movdqu	-57(%edx), %xmm2
	mov	$-57, %ebx
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(41bytes):
	mov	$-41, %ebx
	movdqu	-41(%eax), %xmm1
	movdqu	-41(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(25bytes):
	mov	$-25, %ebx
	movdqu	-25(%eax), %xmm1
	movdqu	-25(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
	mov	-9(%eax), %ecx
	mov	-9(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
	mov	-5(%eax), %ecx
	mov	-5(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
	movzbl	-1(%eax), %ecx
	cmp	-1(%edx), %cl
	mov	$0, %eax
	jne	L(end)
	RETURN

	.p2align 4
L(58bytes):
	movdqu	-58(%eax), %xmm1
	movdqu	-58(%edx), %xmm2
	mov	$-58, %ebx
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(42bytes):
	mov	$-42, %ebx
	movdqu	-42(%eax), %xmm1
	movdqu	-42(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(26bytes):
	mov	$-26, %ebx
	movdqu	-26(%eax), %xmm1
	movdqu	-26(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)

	mov	-10(%eax), %ecx
	mov	-10(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)

	mov	-6(%eax), %ecx
	mov	-6(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)

	movzwl	-2(%eax), %ecx
	movzwl	-2(%edx), %ebx
	cmp	%bl, %cl
	jne	L(end)
	cmp	%bh, %ch
	mov	$0, %eax
	jne	L(end)
	RETURN

	.p2align 4
L(59bytes):
	movdqu	-59(%eax), %xmm1
	movdqu	-59(%edx), %xmm2
	mov	$-59, %ebx
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(43bytes):
	mov	$-43, %ebx
	movdqu	-43(%eax), %xmm1
	movdqu	-43(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(27bytes):
	mov	$-27, %ebx
	movdqu	-27(%eax), %xmm1
	movdqu	-27(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
	movl	-11(%eax), %ecx
	movl	-11(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
	movl	-7(%eax), %ecx
	movl	-7(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
	movzwl	-3(%eax), %ecx
	movzwl	-3(%edx), %ebx
	cmpb	%bl, %cl
	jne	L(end)
	cmp	%bx, %cx
	jne	L(end)
	movzbl	-1(%eax), %eax
	cmpb	-1(%edx), %al
	mov	$0, %eax
	jne	L(end)
	RETURN
# endif
	.p2align 4
L(60bytes):
	movdqu	-60(%eax), %xmm1
	movdqu	-60(%edx), %xmm2
	mov	$-60, %ebx
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(44bytes):
	mov	$-44, %ebx
	movdqu	-44(%eax), %xmm1
	movdqu	-44(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(28bytes):
	mov	$-28, %ebx
	movdqu	-28(%eax), %xmm1
	movdqu	-28(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)

	mov	-12(%eax), %ecx
# ifndef USE_AS_WMEMCMP
	mov	-12(%edx), %ebx
	cmp	%ebx, %ecx
# else
	cmp	-12(%edx), %ecx
# endif
	jne	L(find_diff)

	mov	-8(%eax), %ecx
# ifndef USE_AS_WMEMCMP
	mov	-8(%edx), %ebx
	cmp	%ebx, %ecx
# else
	cmp	-8(%edx), %ecx
# endif
	jne	L(find_diff)

	mov	-4(%eax), %ecx
# ifndef USE_AS_WMEMCMP
	mov	-4(%edx), %ebx
	cmp	%ebx, %ecx
# else
	cmp	-4(%edx), %ecx
# endif
	mov	$0, %eax
	jne	L(find_diff)
	RETURN

# ifndef USE_AS_WMEMCMP
	.p2align 4
L(61bytes):
	movdqu	-61(%eax), %xmm1
	movdqu	-61(%edx), %xmm2
	mov	$-61, %ebx
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(45bytes):
	mov	$-45, %ebx
	movdqu	-45(%eax), %xmm1
	movdqu	-45(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(29bytes):
	mov	$-29, %ebx
	movdqu	-29(%eax), %xmm1
	movdqu	-29(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)

	mov	-13(%eax), %ecx
	mov	-13(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)

	mov	-9(%eax), %ecx
	mov	-9(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)

	mov	-5(%eax), %ecx
	mov	-5(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
	movzbl	-1(%eax), %ecx
	cmp	-1(%edx), %cl
	mov	$0, %eax
	jne	L(end)
	RETURN

	.p2align 4
L(62bytes):
	movdqu	-62(%eax), %xmm1
	movdqu	-62(%edx), %xmm2
	mov	$-62, %ebx
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(46bytes):
	mov	$-46, %ebx
	movdqu	-46(%eax), %xmm1
	movdqu	-46(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(30bytes):
	mov	$-30, %ebx
	movdqu	-30(%eax), %xmm1
	movdqu	-30(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
	mov	-14(%eax), %ecx
	mov	-14(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
	mov	-10(%eax), %ecx
	mov	-10(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
	mov	-6(%eax), %ecx
	mov	-6(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
	movzwl	-2(%eax), %ecx
	movzwl	-2(%edx), %ebx
	cmp	%bl, %cl
	jne	L(end)
	cmp	%bh, %ch
	mov	$0, %eax
	jne	L(end)
	RETURN

	.p2align 4
L(63bytes):
	movdqu	-63(%eax), %xmm1
	movdqu	-63(%edx), %xmm2
	mov	$-63, %ebx
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(47bytes):
	mov	$-47, %ebx
	movdqu	-47(%eax), %xmm1
	movdqu	-47(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(31bytes):
	mov	$-31, %ebx
	movdqu	-31(%eax), %xmm1
	movdqu	-31(%edx), %xmm2
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)

	movl	-15(%eax), %ecx
	movl	-15(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
	movl	-11(%eax), %ecx
	movl	-11(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
	movl	-7(%eax), %ecx
	movl	-7(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)
	movzwl	-3(%eax), %ecx
	movzwl	-3(%edx), %ebx
	cmpb	%bl, %cl
	jne	L(end)
	cmp	%bx, %cx
	jne	L(end)
	movzbl	-1(%eax), %eax
	cmpb	-1(%edx), %al
	mov	$0, %eax
	jne	L(end)
	RETURN
# endif

	.p2align 4
L(64bytes):
	movdqu	-64(%eax), %xmm1
	movdqu	-64(%edx), %xmm2
	mov	$-64, %ebx
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(48bytes):
	movdqu	-48(%eax), %xmm1
	movdqu	-48(%edx), %xmm2
	mov	$-48, %ebx
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)
L(32bytes):
	movdqu	-32(%eax), %xmm1
	movdqu	-32(%edx), %xmm2
	mov	$-32, %ebx
	pxor	%xmm1, %xmm2
	ptest	%xmm2, %xmm0
	jnc	L(less16bytes)

	mov	-16(%eax), %ecx
# ifndef USE_AS_WMEMCMP
	mov	-16(%edx), %ebx
	cmp	%ebx, %ecx
# else
	cmp	-16(%edx), %ecx
# endif
	jne	L(find_diff)

	mov	-12(%eax), %ecx
# ifndef USE_AS_WMEMCMP
	mov	-12(%edx), %ebx
	cmp	%ebx, %ecx
# else
	cmp	-12(%edx), %ecx
# endif
	jne	L(find_diff)

	mov	-8(%eax), %ecx
# ifndef USE_AS_WMEMCMP
	mov	-8(%edx), %ebx
	cmp	%ebx, %ecx
# else
	cmp	-8(%edx), %ecx
# endif
	jne	L(find_diff)

	mov	-4(%eax), %ecx
# ifndef USE_AS_WMEMCMP
	mov	-4(%edx), %ebx
	cmp	%ebx, %ecx
# else
	cmp	-4(%edx), %ecx
# endif
	mov	$0, %eax
	jne	L(find_diff)
	RETURN

# ifndef USE_AS_WMEMCMP
	.p2align 4
L(less16bytes):
	add	%ebx, %eax
	add	%ebx, %edx

	mov	(%eax), %ecx
	mov	(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)

	mov	4(%eax), %ecx
	mov	4(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)

	mov	8(%eax), %ecx
	mov	8(%edx), %ebx
	cmp	%ebx, %ecx
	jne	L(find_diff)

	mov	12(%eax), %ecx
	mov	12(%edx), %ebx
	cmp	%ebx, %ecx
	mov	$0, %eax
	jne	L(find_diff)
	RETURN
# else
	.p2align 4
L(less16bytes):
	add	%ebx, %eax
	add	%ebx, %edx

	mov	(%eax), %ecx
	cmp	(%edx), %ecx
	jne	L(find_diff)

	mov	4(%eax), %ecx
	cmp	4(%edx), %ecx
	jne	L(find_diff)

	mov	8(%eax), %ecx
	cmp	8(%edx), %ecx
	jne	L(find_diff)

	mov	12(%eax), %ecx
	cmp	12(%edx), %ecx

	mov	$0, %eax
	jne	L(find_diff)
	RETURN
# endif

	.p2align 4
L(find_diff):
# ifndef USE_AS_WMEMCMP
	cmpb	%bl, %cl
	jne	L(end)
	cmp	%bx, %cx
	jne	L(end)
	shr	$16,%ecx
	shr	$16,%ebx
	cmp	%bl, %cl
	jne	L(end)
	cmp	%bx, %cx
L(end):
	POP	(%ebx)
	mov	$1, %eax
	ja	L(bigger)
	neg	%eax
L(bigger):
	ret
# else
	POP	(%ebx)
	mov	$1, %eax
	jg	L(bigger)
	neg	%eax
	ret

	.p2align 4
L(bigger):
	ret
# endif
END (MEMCMP)

	.section .rodata.sse4.2,"a",@progbits
	.p2align 2
	.type	L(table_64bytes), @object
# ifndef USE_AS_WMEMCMP
L(table_64bytes):
	.int	JMPTBL (L(0bytes), L(table_64bytes))
	.int	JMPTBL (L(1bytes), L(table_64bytes))
	.int	JMPTBL (L(2bytes), L(table_64bytes))
	.int	JMPTBL (L(3bytes), L(table_64bytes))
	.int	JMPTBL (L(4bytes), L(table_64bytes))
	.int	JMPTBL (L(5bytes), L(table_64bytes))
	.int	JMPTBL (L(6bytes), L(table_64bytes))
	.int	JMPTBL (L(7bytes), L(table_64bytes))
	.int	JMPTBL (L(8bytes), L(table_64bytes))
	.int	JMPTBL (L(9bytes), L(table_64bytes))
	.int	JMPTBL (L(10bytes), L(table_64bytes))
	.int	JMPTBL (L(11bytes), L(table_64bytes))
	.int	JMPTBL (L(12bytes), L(table_64bytes))
	.int	JMPTBL (L(13bytes), L(table_64bytes))
	.int	JMPTBL (L(14bytes), L(table_64bytes))
	.int	JMPTBL (L(15bytes), L(table_64bytes))
	.int	JMPTBL (L(16bytes), L(table_64bytes))
	.int	JMPTBL (L(17bytes), L(table_64bytes))
	.int	JMPTBL (L(18bytes), L(table_64bytes))
	.int	JMPTBL (L(19bytes), L(table_64bytes))
	.int	JMPTBL (L(20bytes), L(table_64bytes))
	.int	JMPTBL (L(21bytes), L(table_64bytes))
	.int	JMPTBL (L(22bytes), L(table_64bytes))
	.int	JMPTBL (L(23bytes), L(table_64bytes))
	.int	JMPTBL (L(24bytes), L(table_64bytes))
	.int	JMPTBL (L(25bytes), L(table_64bytes))
	.int	JMPTBL (L(26bytes), L(table_64bytes))
	.int	JMPTBL (L(27bytes), L(table_64bytes))
	.int	JMPTBL (L(28bytes), L(table_64bytes))
	.int	JMPTBL (L(29bytes), L(table_64bytes))
	.int	JMPTBL (L(30bytes), L(table_64bytes))
	.int	JMPTBL (L(31bytes), L(table_64bytes))
	.int	JMPTBL (L(32bytes), L(table_64bytes))
	.int	JMPTBL (L(33bytes), L(table_64bytes))
	.int	JMPTBL (L(34bytes), L(table_64bytes))
	.int	JMPTBL (L(35bytes), L(table_64bytes))
	.int	JMPTBL (L(36bytes), L(table_64bytes))
	.int	JMPTBL (L(37bytes), L(table_64bytes))
	.int	JMPTBL (L(38bytes), L(table_64bytes))
	.int	JMPTBL (L(39bytes), L(table_64bytes))
	.int	JMPTBL (L(40bytes), L(table_64bytes))
	.int	JMPTBL (L(41bytes), L(table_64bytes))
	.int	JMPTBL (L(42bytes), L(table_64bytes))
	.int	JMPTBL (L(43bytes), L(table_64bytes))
	.int	JMPTBL (L(44bytes), L(table_64bytes))
	.int	JMPTBL (L(45bytes), L(table_64bytes))
	.int	JMPTBL (L(46bytes), L(table_64bytes))
	.int	JMPTBL (L(47bytes), L(table_64bytes))
	.int	JMPTBL (L(48bytes), L(table_64bytes))
	.int	JMPTBL (L(49bytes), L(table_64bytes))
	.int	JMPTBL (L(50bytes), L(table_64bytes))
	.int	JMPTBL (L(51bytes), L(table_64bytes))
	.int	JMPTBL (L(52bytes), L(table_64bytes))
	.int	JMPTBL (L(53bytes), L(table_64bytes))
	.int	JMPTBL (L(54bytes), L(table_64bytes))
	.int	JMPTBL (L(55bytes), L(table_64bytes))
	.int	JMPTBL (L(56bytes), L(table_64bytes))
	.int	JMPTBL (L(57bytes), L(table_64bytes))
	.int	JMPTBL (L(58bytes), L(table_64bytes))
	.int	JMPTBL (L(59bytes), L(table_64bytes))
	.int	JMPTBL (L(60bytes), L(table_64bytes))
	.int	JMPTBL (L(61bytes), L(table_64bytes))
	.int	JMPTBL (L(62bytes), L(table_64bytes))
	.int	JMPTBL (L(63bytes), L(table_64bytes))
	.int	JMPTBL (L(64bytes), L(table_64bytes))
# else
L(table_64bytes):
	.int	JMPTBL (L(0bytes), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(4bytes), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(8bytes), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(12bytes), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(16bytes), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(20bytes), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(24bytes), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(28bytes), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(32bytes), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(36bytes), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(40bytes), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(44bytes), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(48bytes), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(52bytes), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(56bytes), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(60bytes), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(unreal_case), L(table_64bytes))
	.int	JMPTBL (L(64bytes), L(table_64bytes))
# endif
#endif