Skip to content

Commit

Permalink
sparc64: simple microoptimizations for atomic functions
Browse files Browse the repository at this point in the history
Simple microoptimizations for sparc64 atomic functions:
Save one instruction by using a delay slot.
Use %g1 instead of %g7, because %g1 is written earlier.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Mikulas Patocka authored and David S. Miller committed Aug 19, 2010
1 parent 9b3bb86 commit 6ec2747
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions arch/sparc/lib/atomic_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ atomic_add_ret: /* %o0 = increment, %o1 = atomic_ptr */
cas [%o1], %g1, %g7
cmp %g1, %g7
bne,pn %icc, 2f
add %g7, %o0, %g7
sra %g7, 0, %o0
add %g1, %o0, %g1
retl
nop
sra %g1, 0, %o0
2: BACKOFF_SPIN(%o2, %o3, 1b)
.size atomic_add_ret, .-atomic_add_ret

Expand All @@ -68,10 +67,9 @@ atomic_sub_ret: /* %o0 = decrement, %o1 = atomic_ptr */
cas [%o1], %g1, %g7
cmp %g1, %g7
bne,pn %icc, 2f
sub %g7, %o0, %g7
sra %g7, 0, %o0
sub %g1, %o0, %g1
retl
nop
sra %g1, 0, %o0
2: BACKOFF_SPIN(%o2, %o3, 1b)
.size atomic_sub_ret, .-atomic_sub_ret

Expand Down Expand Up @@ -114,10 +112,9 @@ atomic64_add_ret: /* %o0 = increment, %o1 = atomic_ptr */
casx [%o1], %g1, %g7
cmp %g1, %g7
bne,pn %xcc, 2f
add %g7, %o0, %g7
mov %g7, %o0
retl
nop
retl
add %g1, %o0, %o0
2: BACKOFF_SPIN(%o2, %o3, 1b)
.size atomic64_add_ret, .-atomic64_add_ret

Expand All @@ -130,9 +127,8 @@ atomic64_sub_ret: /* %o0 = decrement, %o1 = atomic_ptr */
casx [%o1], %g1, %g7
cmp %g1, %g7
bne,pn %xcc, 2f
sub %g7, %o0, %g7
mov %g7, %o0
retl
nop
retl
sub %g1, %o0, %o0
2: BACKOFF_SPIN(%o2, %o3, 1b)
.size atomic64_sub_ret, .-atomic64_sub_ret

0 comments on commit 6ec2747

Please sign in to comment.