riscv: Fix feenvupdate with FE_DFL_ENV (BZ 31022)
[glibc.git] / sysdeps / s390 / strcmp-vx.S
blob69dc370dbb4043161d2aa91c78d7cb3922385d9e
1 /* Vector optimized 32/64 bit S/390 version of strcmp.
2    Copyright (C) 2015-2023 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <https://www.gnu.org/licenses/>.  */
19 #include <ifunc-strcmp.h>
20 #if HAVE_STRCMP_Z13
22 # include "sysdep.h"
23 # include "asm-syntax.h"
25         .text
27 /* int strcmp (const char *s1, const char *s2)
28    Compare two strings
30    Register usage:
31    -r1=loaded byte count s1
32    -r2=s1
33    -r3=s2
34    -r4=loaded byte coutn s2, tmp
35    -r5=current_len
36    -v16=part of s1
37    -v17=part of s2
38    -v18=index of unequal
40 ENTRY(STRCMP_Z13)
41         .machine "z13"
42         .machinemode "zarch_nohighgprs"
44         lghi    %r5,0           /* current_len = 0.  */
46 .Lloop:
47         vlbb    %v16,0(%r5,%r2),6 /* Load s1 to block boundary.  */
48         vlbb    %v17,0(%r5,%r3),6 /* Load s2 to block boundary.  */
49         lcbb    %r1,0(%r5,%r2),6 /* Get loaded byte count of s1.  */
50         jo      .Llt16_1        /* Jump away if vr is not fully loaded.  */
51         lcbb    %r4,0(%r5,%r3),6
52         jo      .Llt16_2        /* Jump away if vr is not fully loaded.  */
53         /* Both vrs are fully loaded.  */
54         aghi    %r5,16
55         vfenezbs %v18,%v16,%v17 /* Compare not equal with zero search.  */
56         jno     .Lfound
58         vlbb    %v16,0(%r5,%r2),6
59         vlbb    %v17,0(%r5,%r3),6
60         lcbb    %r1,0(%r5,%r2),6
61         jo      .Llt16_1
62         lcbb    %r4,0(%r5,%r3),6
63         jo      .Llt16_2
64         aghi    %r5,16
65         vfenezbs %v18,%v16,%v17
66         jno     .Lfound
68         vlbb    %v16,0(%r5,%r2),6
69         vlbb    %v17,0(%r5,%r3),6
70         lcbb    %r1,0(%r5,%r2),6
71         jo      .Llt16_1
72         lcbb    %r4,0(%r5,%r3),6
73         jo      .Llt16_2
74         aghi    %r5,16
75         vfenezbs %v18,%v16,%v17
76         jno     .Lfound
78         vlbb    %v16,0(%r5,%r2),6
79         vlbb    %v17,0(%r5,%r3),6
80         lcbb    %r1,0(%r5,%r2),6
81         jo      .Llt16_1
82         lcbb    %r4,0(%r5,%r3),6
83         jo      .Llt16_2
84         aghi    %r5,16
85         vfenezbs %v18,%v16,%v17
86         jno     .Lfound
87         j       .Lloop
89 .Llt16_1:
90         lcbb    %r4,0(%r5,%r3),6 /* Get loaded byte count of s2.  */
91 .Llt16_2:
92         clr     %r1,%r4
93         locrh   %r1,%r4         /* Get minimum of bytes loaded in s1/2.  */
94         algfr   %r5,%r1         /* Add smallest loaded bytes to current_len.  */
95         vfenezbs %v18,%v16,%v17 /* Compare not equal with zero search.  */
96         vlgvb   %r4,%v18,7      /* Get not equal index or 16 if all equal.  */
97         clrjl   %r4,%r1,.Lfound /* Jump away if miscompare is within loaded
98                                     bytes.  */
99         j       .Lloop
101 .Lfound:
102         je      .Lend_equal
103         lghi    %r2,1
104         lghi    %r1,-1
105         locgrl  %r2,%r1
106         br      %r14
107 .Lend_equal:
108         lghi    %r2,0
109         br      %r14
110 END(STRCMP_Z13)
112 # if ! HAVE_STRCMP_IFUNC
113 strong_alias (STRCMP_Z13, strcmp)
114 # endif
116 # if ! HAVE_STRCMP_Z900_G5 && defined SHARED && IS_IN (libc)
117 strong_alias (STRCMP_Z13, __GI_strcmp)
118 # endif
119 #endif