Skip to content

Commit d191323

Browse files
committed
xtensa: don't use a12 in strncpy_user
a12 is callee-saved register in xtensa call0 ABI, so a function must not change it. a10 is not used in this function at all, use it instead of a12 to avoid saving/restoring it. Signed-off-by: Max Filippov <[email protected]>
1 parent eda8dd1 commit d191323

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

arch/xtensa/lib/strncpy_user.S

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
# a9/ tmp
4646
# a10/ tmp
4747
# a11/ dst
48-
# a12/ tmp
4948

5049
.text
5150
ENTRY(__strncpy_user)
@@ -61,7 +60,7 @@ ENTRY(__strncpy_user)
6160
bbsi.l a3, 0, .Lsrc1mod2 # if only 8-bit aligned
6261
bbsi.l a3, 1, .Lsrc2mod4 # if only 16-bit aligned
6362
.Lsrcaligned: # return here when src is word-aligned
64-
srli a12, a4, 2 # number of loop iterations with 4B per loop
63+
srli a10, a4, 2 # number of loop iterations with 4B per loop
6564
movi a9, 3
6665
bnone a11, a9, .Laligned
6766
j .Ldstunaligned
@@ -102,11 +101,11 @@ EX(10f) s8i a9, a11, 0 # store byte 0
102101
.byte 0 # (0 mod 4 alignment for LBEG)
103102
.Laligned:
104103
#if XCHAL_HAVE_LOOPS
105-
loopnez a12, .Loop1done
104+
loopnez a10, .Loop1done
106105
#else
107-
beqz a12, .Loop1done
108-
slli a12, a12, 2
109-
add a12, a12, a11 # a12 = end of last 4B chunck
106+
beqz a10, .Loop1done
107+
slli a10, a10, 2
108+
add a10, a10, a11 # a10 = end of last 4B chunck
110109
#endif
111110
.Loop1:
112111
EX(11f) l32i a9, a3, 0 # get word from src
@@ -118,7 +117,7 @@ EX(10f) s32i a9, a11, 0 # store word to dst
118117
bnone a9, a8, .Lz3 # if byte 3 is zero
119118
addi a11, a11, 4 # advance dst pointer
120119
#if !XCHAL_HAVE_LOOPS
121-
blt a11, a12, .Loop1
120+
blt a11, a10, .Loop1
122121
#endif
123122

124123
.Loop1done:
@@ -185,7 +184,7 @@ EX(10f) s8i a9, a11, 2
185184
loopnez a4, .Lunalignedend
186185
#else
187186
beqz a4, .Lunalignedend
188-
add a12, a11, a4 # a12 = ending address
187+
add a10, a11, a4 # a10 = ending address
189188
#endif /* XCHAL_HAVE_LOOPS */
190189
.Lnextbyte:
191190
EX(11f) l8ui a9, a3, 0
@@ -194,7 +193,7 @@ EX(10f) s8i a9, a11, 0
194193
beqz a9, .Lunalignedend
195194
addi a11, a11, 1
196195
#if !XCHAL_HAVE_LOOPS
197-
blt a11, a12, .Lnextbyte
196+
blt a11, a10, .Lnextbyte
198197
#endif
199198

200199
.Lunalignedend:

0 commit comments

Comments
 (0)