[MIPS] Improve branch prediction in ll/sc atomic operations.
Now that finally all supported versions of binutils have functioning support for .subsection use .subsection to tweak the branch prediction I did not modify the R10000 errata variants because it seems unclear if this will invalidate the workaround which actually relies on the cheesy prediction of branch likely to cause a misspredict if the sc was successful. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
@@ -69,7 +69,10 @@ static __inline__ void atomic_add(int i, atomic_t * v)
|
||||
"1: ll %0, %1 # atomic_add \n"
|
||||
" addu %0, %2 \n"
|
||||
" sc %0, %1 \n"
|
||||
" beqz %0, 1b \n"
|
||||
" beqz %0, 2f \n"
|
||||
" .subsection 2 \n"
|
||||
"2: b 1b \n"
|
||||
" .previous \n"
|
||||
" .set mips0 \n"
|
||||
: "=&r" (temp), "=m" (v->counter)
|
||||
: "Ir" (i), "m" (v->counter));
|
||||
@@ -111,7 +114,10 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
|
||||
"1: ll %0, %1 # atomic_sub \n"
|
||||
" subu %0, %2 \n"
|
||||
" sc %0, %1 \n"
|
||||
" beqz %0, 1b \n"
|
||||
" beqz %0, 2f \n"
|
||||
" .subsection 2 \n"
|
||||
"2: b 1b \n"
|
||||
" .previous \n"
|
||||
" .set mips0 \n"
|
||||
: "=&r" (temp), "=m" (v->counter)
|
||||
: "Ir" (i), "m" (v->counter));
|
||||
@@ -155,8 +161,11 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
|
||||
"1: ll %1, %2 # atomic_add_return \n"
|
||||
" addu %0, %1, %3 \n"
|
||||
" sc %0, %2 \n"
|
||||
" beqz %0, 1b \n"
|
||||
" beqz %0, 2f \n"
|
||||
" addu %0, %1, %3 \n"
|
||||
" .subsection 2 \n"
|
||||
"2: b 1b \n"
|
||||
" .previous \n"
|
||||
" .set mips0 \n"
|
||||
: "=&r" (result), "=&r" (temp), "=m" (v->counter)
|
||||
: "Ir" (i), "m" (v->counter)
|
||||
@@ -204,8 +213,11 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
|
||||
"1: ll %1, %2 # atomic_sub_return \n"
|
||||
" subu %0, %1, %3 \n"
|
||||
" sc %0, %2 \n"
|
||||
" beqz %0, 1b \n"
|
||||
" beqz %0, 2f \n"
|
||||
" subu %0, %1, %3 \n"
|
||||
" .subsection 2 \n"
|
||||
"2: b 1b \n"
|
||||
" .previous \n"
|
||||
" .set mips0 \n"
|
||||
: "=&r" (result), "=&r" (temp), "=m" (v->counter)
|
||||
: "Ir" (i), "m" (v->counter)
|
||||
@@ -267,10 +279,13 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
|
||||
" bltz %0, 1f \n"
|
||||
" sc %0, %2 \n"
|
||||
" .set noreorder \n"
|
||||
" beqz %0, 1b \n"
|
||||
" beqz %0, 2f \n"
|
||||
" subu %0, %1, %3 \n"
|
||||
" .set reorder \n"
|
||||
"1: \n"
|
||||
" .subsection 2 \n"
|
||||
"2: b 1b \n"
|
||||
" .previous \n"
|
||||
" .set mips0 \n"
|
||||
: "=&r" (result), "=&r" (temp), "=m" (v->counter)
|
||||
: "Ir" (i), "m" (v->counter)
|
||||
@@ -429,7 +444,10 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
|
||||
"1: lld %0, %1 # atomic64_add \n"
|
||||
" addu %0, %2 \n"
|
||||
" scd %0, %1 \n"
|
||||
" beqz %0, 1b \n"
|
||||
" beqz %0, 2f \n"
|
||||
" .subsection 2 \n"
|
||||
"2: b 1b \n"
|
||||
" .previous \n"
|
||||
" .set mips0 \n"
|
||||
: "=&r" (temp), "=m" (v->counter)
|
||||
: "Ir" (i), "m" (v->counter));
|
||||
@@ -471,7 +489,10 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
|
||||
"1: lld %0, %1 # atomic64_sub \n"
|
||||
" subu %0, %2 \n"
|
||||
" scd %0, %1 \n"
|
||||
" beqz %0, 1b \n"
|
||||
" beqz %0, 2f \n"
|
||||
" .subsection 2 \n"
|
||||
"2: b 1b \n"
|
||||
" .previous \n"
|
||||
" .set mips0 \n"
|
||||
: "=&r" (temp), "=m" (v->counter)
|
||||
: "Ir" (i), "m" (v->counter));
|
||||
@@ -515,8 +536,11 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
|
||||
"1: lld %1, %2 # atomic64_add_return \n"
|
||||
" addu %0, %1, %3 \n"
|
||||
" scd %0, %2 \n"
|
||||
" beqz %0, 1b \n"
|
||||
" beqz %0, 2f \n"
|
||||
" addu %0, %1, %3 \n"
|
||||
" .subsection 2 \n"
|
||||
"2: b 1b \n"
|
||||
" .previous \n"
|
||||
" .set mips0 \n"
|
||||
: "=&r" (result), "=&r" (temp), "=m" (v->counter)
|
||||
: "Ir" (i), "m" (v->counter)
|
||||
@@ -564,8 +588,11 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
|
||||
"1: lld %1, %2 # atomic64_sub_return \n"
|
||||
" subu %0, %1, %3 \n"
|
||||
" scd %0, %2 \n"
|
||||
" beqz %0, 1b \n"
|
||||
" beqz %0, 2f \n"
|
||||
" subu %0, %1, %3 \n"
|
||||
" .subsection 2 \n"
|
||||
"2: b 1b \n"
|
||||
" .previous \n"
|
||||
" .set mips0 \n"
|
||||
: "=&r" (result), "=&r" (temp), "=m" (v->counter)
|
||||
: "Ir" (i), "m" (v->counter)
|
||||
@@ -627,10 +654,13 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
|
||||
" bltz %0, 1f \n"
|
||||
" scd %0, %2 \n"
|
||||
" .set noreorder \n"
|
||||
" beqz %0, 1b \n"
|
||||
" beqz %0, 2f \n"
|
||||
" dsubu %0, %1, %3 \n"
|
||||
" .set reorder \n"
|
||||
"1: \n"
|
||||
" .subsection 2 \n"
|
||||
"2: b 1b \n"
|
||||
" .previous \n"
|
||||
" .set mips0 \n"
|
||||
: "=&r" (result), "=&r" (temp), "=m" (v->counter)
|
||||
: "Ir" (i), "m" (v->counter)
|
||||
|
Reference in New Issue
Block a user