Skip to content

Commit 745600e

Browse files
svens-s390Alexander Gordeev
authored andcommitted
s390/lib: Use exrl instead of ex in xor functions
exrl is present in all machines currently supported, therefore prefer it over ex. This saves one instruction and doesn't need an additional register to hold the address of the target instruction. Signed-off-by: Sven Schnelle <[email protected]> Reviewed-by: Heiko Carstens <[email protected]> Signed-off-by: Alexander Gordeev <[email protected]>
1 parent 9988df0 commit 745600e

File tree

1 file changed

+29
-32
lines changed

1 file changed

+29
-32
lines changed

arch/s390/lib/xor.c

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ static void xor_xc_2(unsigned long bytes, unsigned long * __restrict p1,
1515
const unsigned long * __restrict p2)
1616
{
1717
asm volatile(
18-
" larl 1,2f\n"
1918
" aghi %0,-1\n"
2019
" jm 3f\n"
2120
" srlg 0,%0,8\n"
@@ -25,22 +24,21 @@ static void xor_xc_2(unsigned long bytes, unsigned long * __restrict p1,
2524
" la %1,256(%1)\n"
2625
" la %2,256(%2)\n"
2726
" brctg 0,0b\n"
28-
"1: ex %0,0(1)\n"
27+
"1: exrl %0,2f\n"
2928
" j 3f\n"
3029
"2: xc 0(1,%1),0(%2)\n"
3130
"3:\n"
3231
: : "d" (bytes), "a" (p1), "a" (p2)
33-
: "0", "1", "cc", "memory");
32+
: "0", "cc", "memory");
3433
}
3534

3635
static void xor_xc_3(unsigned long bytes, unsigned long * __restrict p1,
3736
const unsigned long * __restrict p2,
3837
const unsigned long * __restrict p3)
3938
{
4039
asm volatile(
41-
" larl 1,2f\n"
4240
" aghi %0,-1\n"
43-
" jm 3f\n"
41+
" jm 4f\n"
4442
" srlg 0,%0,8\n"
4543
" ltgr 0,0\n"
4644
" jz 1f\n"
@@ -50,14 +48,14 @@ static void xor_xc_3(unsigned long bytes, unsigned long * __restrict p1,
5048
" la %2,256(%2)\n"
5149
" la %3,256(%3)\n"
5250
" brctg 0,0b\n"
53-
"1: ex %0,0(1)\n"
54-
" ex %0,6(1)\n"
55-
" j 3f\n"
51+
"1: exrl %0,2f\n"
52+
" exrl %0,3f\n"
53+
" j 4f\n"
5654
"2: xc 0(1,%1),0(%2)\n"
57-
" xc 0(1,%1),0(%3)\n"
58-
"3:\n"
55+
"3: xc 0(1,%1),0(%3)\n"
56+
"4:\n"
5957
: "+d" (bytes), "+a" (p1), "+a" (p2), "+a" (p3)
60-
: : "0", "1", "cc", "memory");
58+
: : "0", "cc", "memory");
6159
}
6260

6361
static void xor_xc_4(unsigned long bytes, unsigned long * __restrict p1,
@@ -66,9 +64,8 @@ static void xor_xc_4(unsigned long bytes, unsigned long * __restrict p1,
6664
const unsigned long * __restrict p4)
6765
{
6866
asm volatile(
69-
" larl 1,2f\n"
7067
" aghi %0,-1\n"
71-
" jm 3f\n"
68+
" jm 5f\n"
7269
" srlg 0,%0,8\n"
7370
" ltgr 0,0\n"
7471
" jz 1f\n"
@@ -80,16 +77,16 @@ static void xor_xc_4(unsigned long bytes, unsigned long * __restrict p1,
8077
" la %3,256(%3)\n"
8178
" la %4,256(%4)\n"
8279
" brctg 0,0b\n"
83-
"1: ex %0,0(1)\n"
84-
" ex %0,6(1)\n"
85-
" ex %0,12(1)\n"
86-
" j 3f\n"
80+
"1: exrl %0,2f\n"
81+
" exrl %0,3f\n"
82+
" exrl %0,4f\n"
83+
" j 5f\n"
8784
"2: xc 0(1,%1),0(%2)\n"
88-
" xc 0(1,%1),0(%3)\n"
89-
" xc 0(1,%1),0(%4)\n"
90-
"3:\n"
85+
"3: xc 0(1,%1),0(%3)\n"
86+
"4: xc 0(1,%1),0(%4)\n"
87+
"5:\n"
9188
: "+d" (bytes), "+a" (p1), "+a" (p2), "+a" (p3), "+a" (p4)
92-
: : "0", "1", "cc", "memory");
89+
: : "0", "cc", "memory");
9390
}
9491

9592
static void xor_xc_5(unsigned long bytes, unsigned long * __restrict p1,
@@ -101,7 +98,7 @@ static void xor_xc_5(unsigned long bytes, unsigned long * __restrict p1,
10198
asm volatile(
10299
" larl 1,2f\n"
103100
" aghi %0,-1\n"
104-
" jm 3f\n"
101+
" jm 6f\n"
105102
" srlg 0,%0,8\n"
106103
" ltgr 0,0\n"
107104
" jz 1f\n"
@@ -115,19 +112,19 @@ static void xor_xc_5(unsigned long bytes, unsigned long * __restrict p1,
115112
" la %4,256(%4)\n"
116113
" la %5,256(%5)\n"
117114
" brctg 0,0b\n"
118-
"1: ex %0,0(1)\n"
119-
" ex %0,6(1)\n"
120-
" ex %0,12(1)\n"
121-
" ex %0,18(1)\n"
122-
" j 3f\n"
115+
"1: exrl %0,2f\n"
116+
" exrl %0,3f\n"
117+
" exrl %0,4f\n"
118+
" exrl %0,5f\n"
119+
" j 6f\n"
123120
"2: xc 0(1,%1),0(%2)\n"
124-
" xc 0(1,%1),0(%3)\n"
125-
" xc 0(1,%1),0(%4)\n"
126-
" xc 0(1,%1),0(%5)\n"
127-
"3:\n"
121+
"3: xc 0(1,%1),0(%3)\n"
122+
"4: xc 0(1,%1),0(%4)\n"
123+
"5: xc 0(1,%1),0(%5)\n"
124+
"6:\n"
128125
: "+d" (bytes), "+a" (p1), "+a" (p2), "+a" (p3), "+a" (p4),
129126
"+a" (p5)
130-
: : "0", "1", "cc", "memory");
127+
: : "0", "cc", "memory");
131128
}
132129

133130
struct xor_block_template xor_block_xc = {

0 commit comments

Comments
 (0)