Linux MIPS Architecture development
 help / color / mirror / Atom feed
* PATCH: Not use branch likely on mips
@ 2002-02-06  2:02 H . J . Lu
  2002-02-07 10:38 ` Andreas Jaeger
  0 siblings, 1 reply; 6+ messages in thread
From: H . J . Lu @ 2002-02-06  2:02 UTC (permalink / raw)
  To: linux-mips, GNU C Library

This patch removes branch likely.


H.J.
----
2002-02-05  H.J. Lu  <hjl@gnu.org>

	* sysdeps/mips/pspinlock.c (__pthread_spin_lock): Not use
	branch likely.
	* sysdeps/mips/pt-machine.h (testandset): Liekwise.
	(__compare_and_swap): Liekwise.

2002-02-05  H.J. Lu  <hjl@gnu.org>

	* sysdeps/mips/atomicity.h (exchange_and_add): Not use branch
	likely.
	(atomic_add): Likewise.
	(compare_and_swap): Likewise.
	* sysdeps/unix/sysv/linux/mips/sys/tas.h (_test_and_set):
	Likewise.

--- libc/linuxthreads/sysdeps/mips/pspinlock.c.llsc	Mon Feb  4 13:45:01 2002
+++ libc/linuxthreads/sysdeps/mips/pspinlock.c	Tue Feb  5 14:11:01 2002
@@ -32,17 +32,16 @@ __pthread_spin_lock (pthread_spinlock_t 
   unsigned int tmp1, tmp2;
 
   asm volatile
-    ("\t\t\t# spin_lock\n\t"
-     "ll	%1,%3\n"
+    ("\t\t\t# spin_lock\n"
      "1:\n\t"
+     "ll	%1,%3\n\t"
      ".set	push\n\t"
      ".set	noreorder\n\t"
      "bnez	%1,1b\n\t"
      " li	%2,1\n\t"
+     ".set	pop\n\t"
      "sc	%2,%0\n\t"
-     "beqzl	%2,1b\n\t"
-     " ll	%1,%3\n\t"
-     ".set	pop"
+     "beqz	%2,1b"
      : "=m" (*lock), "=&r" (tmp1), "=&r" (tmp2)
      : "m" (*lock)
      : "memory");
--- libc/linuxthreads/sysdeps/mips/pt-machine.h.llsc	Mon Feb  4 13:45:01 2002
+++ libc/linuxthreads/sysdeps/mips/pt-machine.h	Tue Feb  5 14:01:11 2002
@@ -57,18 +57,17 @@ __compare_and_swap (long int *p, long in
   long int ret, temp;
 
   __asm__ __volatile__
-    ("/* Inline compare & swap */\n\t"
-     "ll	%1,%5\n"
+    ("/* Inline compare & swap */\n"
      "1:\n\t"
+     "ll	%1,%5\n\t"
      ".set	push\n\t"
      ".set	noreorder\n\t"
      "bne	%1,%3,2f\n\t"
      " move	%0,$0\n\t"
+     ".set	pop\n\t"
      "move	%0,%4\n\t"
      "sc	%0,%2\n\t"
-     "beqzl	%0,1b\n\t"
-     " ll	%1,%5\n\t"
-     ".set	pop\n"
+     "beqz	%0,1b\n"
      "2:\n\t"
      "/* End compare & swap */"
      : "=&r" (ret), "=&r" (temp), "=m" (*p)
--- libc/sysdeps/mips/atomicity.h.llsc	Mon Feb  4 13:45:18 2002
+++ libc/sysdeps/mips/atomicity.h	Tue Feb  5 13:58:59 2002
@@ -32,16 +32,12 @@ exchange_and_add (volatile uint32_t *mem
   int result, tmp;
 
   __asm__ __volatile__
-    ("/* Inline exchange & add */\n\t"
-     "ll	%0,%3\n"
+    ("/* Inline exchange & add */\n"
      "1:\n\t"
+     "ll	%0,%3\n\t"
      "addu	%1,%4,%0\n\t"
      "sc	%1,%2\n\t"
-     ".set	push\n\t"
-     ".set	noreorder\n\t"
-     "beqzl	%1,1b\n\t"
-     " ll	%0,%3\n\t"
-     ".set	pop\n\t"
+     "beqz	%1,1b\n\t"
      "/* End exchange & add */"
      : "=&r"(result), "=&r"(tmp), "=m"(*mem)
      : "m" (*mem), "r"(val)
@@ -57,16 +53,12 @@ atomic_add (volatile uint32_t *mem, int 
   int result;
 
   __asm__ __volatile__
-    ("/* Inline atomic add */\n\t"
-     "ll	%0,%2\n"
+    ("/* Inline atomic add */\n"
      "1:\n\t"
+     "ll	%0,%2\n\t"
      "addu	%0,%3,%0\n\t"
      "sc	%0,%1\n\t"
-     ".set	push\n\t"
-     ".set	noreorder\n\t"
-     "beqzl	%0,1b\n\t"
-     " ll	%0,%2\n\t"
-     ".set	pop\n\t"
+     "beqz	%0,1b\n\t"
      "/* End atomic add */"
      : "=&r"(result), "=m"(*mem)
      : "m" (*mem), "r"(val)
@@ -80,18 +72,17 @@ compare_and_swap (volatile long int *p, 
   long int ret, temp;
 
   __asm__ __volatile__
-    ("/* Inline compare & swap */\n\t"
-     "ll	%1,%5\n"
+    ("/* Inline compare & swap */\n"
      "1:\n\t"
+     "ll	%1,%5\n\t"
      ".set	push\n\t"
      ".set	noreorder\n\t"
      "bne	%1,%3,2f\n\t"
      " move	%0,$0\n\t"
+     ".set	pop\n\t"
      "move	%0,%4\n\t"
      "sc	%0,%2\n\t"
-     "beqzl	%0,1b\n\t"
-     " ll	%1,%5\n\t"
-     ".set	pop\n"
+     "beqz	%0,1b\n"
      "2:\n\t"
      "/* End compare & swap */"
      : "=&r" (ret), "=&r" (temp), "=m" (*p)
--- libc/sysdeps/unix/sysv/linux/mips/sys/tas.h.llsc	Mon Feb  4 13:45:28 2002
+++ libc/sysdeps/unix/sysv/linux/mips/sys/tas.h	Tue Feb  5 13:59:52 2002
@@ -42,17 +42,16 @@ _test_and_set (int *p, int v) __THROW
   int r, t;
 
   __asm__ __volatile__
-    ("/* Inline test and set */\n\t"
-     "ll	%0,%3\n"
+    ("/* Inline test and set */\n"
      "1:\n\t"
+     "ll	%0,%3\n\t"
      ".set	push\n\t"
      ".set	noreorder\n\t"
      "beq	%0,%4,2f\n\t"
      " move	%1,%4\n\t"
+     ".set	pop\n\t"
      "sc	%1,%2\n\t"
-     "beqzl	%1,1b\n\t"
-     " ll	%0,%3\n\t"
-     ".set	pop\n"
+     "beqz	%1,1b\n"
      "2:\n\t"
      "/* End test and set */"
      : "=&r" (r), "=&r" (t), "=m" (*p)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PATCH: Not use branch likely on mips
  2002-02-06  2:02 PATCH: Not use branch likely on mips H . J . Lu
@ 2002-02-07 10:38 ` Andreas Jaeger
  2002-02-07 17:13   ` H . J . Lu
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Jaeger @ 2002-02-07 10:38 UTC (permalink / raw)
  To: H . J . Lu; +Cc: linux-mips, GNU C Library

"H . J . Lu" <hjl@lucon.org> writes:

> This patch removes branch likely.

Please update the copyright years next time.

I've committed the patch,

Andreas

>
> H.J.
> ----
> 2002-02-05  H.J. Lu  <hjl@gnu.org>
>
> 	* sysdeps/mips/pspinlock.c (__pthread_spin_lock): Not use
> 	branch likely.
> 	* sysdeps/mips/pt-machine.h (testandset): Liekwise.
> 	(__compare_and_swap): Liekwise.
>
> 2002-02-05  H.J. Lu  <hjl@gnu.org>
>
> 	* sysdeps/mips/atomicity.h (exchange_and_add): Not use branch
> 	likely.
> 	(atomic_add): Likewise.
> 	(compare_and_swap): Likewise.
> 	* sysdeps/unix/sysv/linux/mips/sys/tas.h (_test_and_set):
> 	Likewise.
> [...]
-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PATCH: Not use branch likely on mips
  2002-02-07 10:38 ` Andreas Jaeger
@ 2002-02-07 17:13   ` H . J . Lu
  2002-02-08  8:00     ` Andreas Jaeger
  2002-02-08 16:15     ` Andreas Jaeger
  0 siblings, 2 replies; 6+ messages in thread
From: H . J . Lu @ 2002-02-07 17:13 UTC (permalink / raw)
  To: Andreas Jaeger; +Cc: linux-mips, GNU C Library

On Thu, Feb 07, 2002 at 11:38:09AM +0100, Andreas Jaeger wrote:
> "H . J . Lu" <hjl@lucon.org> writes:
> 
> > This patch removes branch likely.
> 
> Please update the copyright years next time.
> 
> I've committed the patch,
> 

Here is a new patch. I have checked in a gcc patch which makes
".set noreorder" unnecessary even with "gcc -g".

Thanks.


H.J.
----
2002-02-07  H.J. Lu  <hjl@gnu.org>

	* sysdeps/mips/pspinlock.c (__pthread_spin_lock): Silence the
	gcc warning.
	(__pthread_spin_lock): Remove ".set noreorder".
	* sysdeps/mips/pt-machine.h (__compare_and_swap): Liekwise.

2002-02-07  H.J. Lu  <hjl@gnu.org>

	* sysdeps/mips/atomicity.h (compare_and_swap): Remove
	".set noreorder".
	* sysdeps/unix/sysv/linux/mips/sys/tas.h (_test_and_set):
	Likewise.

--- libc/linuxthreads/sysdeps/mips/pspinlock.c.llsc	Thu Feb  7 08:48:57 2002
+++ libc/linuxthreads/sysdeps/mips/pspinlock.c	Wed Feb  6 12:12:50 2002
@@ -35,11 +35,8 @@ __pthread_spin_lock (pthread_spinlock_t 
     ("\t\t\t# spin_lock\n"
      "1:\n\t"
      "ll	%1,%3\n\t"
-     ".set	push\n\t"
-     ".set	noreorder\n\t"
+     "li	%2,1\n\t"
      "bnez	%1,1b\n\t"
-     " li	%2,1\n\t"
-     ".set	pop\n\t"
      "sc	%2,%0\n\t"
      "beqz	%2,1b"
      : "=m" (*lock), "=&r" (tmp1), "=&r" (tmp2)
@@ -54,7 +51,7 @@ __pthread_spin_lock (pthread_spinlock_t 
 int
 __pthread_spin_lock (pthread_spinlock_t *lock)
 {
-  while (_test_and_set (lock, 1));
+  while (_test_and_set ((int *) lock, 1));
   return 0;
 }
 
--- libc/linuxthreads/sysdeps/mips/pt-machine.h.llsc	Thu Feb  7 08:48:57 2002
+++ libc/linuxthreads/sysdeps/mips/pt-machine.h	Wed Feb  6 12:12:50 2002
@@ -60,11 +60,8 @@ __compare_and_swap (long int *p, long in
     ("/* Inline compare & swap */\n"
      "1:\n\t"
      "ll	%1,%5\n\t"
-     ".set	push\n\t"
-     ".set	noreorder\n\t"
+     "move	%0,$0\n\t"
      "bne	%1,%3,2f\n\t"
-     " move	%0,$0\n\t"
-     ".set	pop\n\t"
      "move	%0,%4\n\t"
      "sc	%0,%2\n\t"
      "beqz	%0,1b\n"
--- libc/sysdeps/mips/atomicity.h.llsc	Thu Feb  7 08:50:14 2002
+++ libc/sysdeps/mips/atomicity.h	Wed Feb  6 12:12:50 2002
@@ -75,11 +75,8 @@ compare_and_swap (volatile long int *p, 
     ("/* Inline compare & swap */\n"
      "1:\n\t"
      "ll	%1,%5\n\t"
-     ".set	push\n\t"
-     ".set	noreorder\n\t"
+     "move	%0,$0\n\t"
      "bne	%1,%3,2f\n\t"
-     " move	%0,$0\n\t"
-     ".set	pop\n\t"
      "move	%0,%4\n\t"
      "sc	%0,%2\n\t"
      "beqz	%0,1b\n"
--- libc/sysdeps/unix/sysv/linux/mips/sys/tas.h.llsc	Thu Feb  7 08:50:15 2002
+++ libc/sysdeps/unix/sysv/linux/mips/sys/tas.h	Wed Feb  6 12:12:50 2002
@@ -45,11 +45,8 @@ _test_and_set (int *p, int v) __THROW
     ("/* Inline test and set */\n"
      "1:\n\t"
      "ll	%0,%3\n\t"
-     ".set	push\n\t"
-     ".set	noreorder\n\t"
+     "move	%1,%4\n\t"
      "beq	%0,%4,2f\n\t"
-     " move	%1,%4\n\t"
-     ".set	pop\n\t"
      "sc	%1,%2\n\t"
      "beqz	%1,1b\n"
      "2:\n\t"

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PATCH: Not use branch likely on mips
  2002-02-07 17:13   ` H . J . Lu
@ 2002-02-08  8:00     ` Andreas Jaeger
  2002-02-08 12:03       ` Maciej W. Rozycki
  2002-02-08 16:15     ` Andreas Jaeger
  1 sibling, 1 reply; 6+ messages in thread
From: Andreas Jaeger @ 2002-02-08  8:00 UTC (permalink / raw)
  To: H . J . Lu; +Cc: linux-mips, GNU C Library

"H . J . Lu" <hjl@lucon.org> writes:

> On Thu, Feb 07, 2002 at 11:38:09AM +0100, Andreas Jaeger wrote:
>> "H . J . Lu" <hjl@lucon.org> writes:
>> 
>> > This patch removes branch likely.
>> 
>> Please update the copyright years next time.
>> 
>> I've committed the patch,
>> 
>
> Here is a new patch. I have checked in a gcc patch which makes
> ".set noreorder" unnecessary even with "gcc -g".

But what about current GCC releases?  Does it work there also without
problems?

Andreas
-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PATCH: Not use branch likely on mips
  2002-02-08  8:00     ` Andreas Jaeger
@ 2002-02-08 12:03       ` Maciej W. Rozycki
  0 siblings, 0 replies; 6+ messages in thread
From: Maciej W. Rozycki @ 2002-02-08 12:03 UTC (permalink / raw)
  To: Andreas Jaeger; +Cc: H . J . Lu, linux-mips, GNU C Library

On Fri, 8 Feb 2002, Andreas Jaeger wrote:

> > Here is a new patch. I have checked in a gcc patch which makes
> > ".set noreorder" unnecessary even with "gcc -g".
> 
> But what about current GCC releases?  Does it work there also without
> problems?

 At worst you lose a few cycles for superfluous nops.

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PATCH: Not use branch likely on mips
  2002-02-07 17:13   ` H . J . Lu
  2002-02-08  8:00     ` Andreas Jaeger
@ 2002-02-08 16:15     ` Andreas Jaeger
  1 sibling, 0 replies; 6+ messages in thread
From: Andreas Jaeger @ 2002-02-08 16:15 UTC (permalink / raw)
  To: H . J . Lu; +Cc: linux-mips, GNU C Library

"H . J . Lu" <hjl@lucon.org> writes:

> On Thu, Feb 07, 2002 at 11:38:09AM +0100, Andreas Jaeger wrote:
>> "H . J . Lu" <hjl@lucon.org> writes:
>> 
>> > This patch removes branch likely.
>> 
>> Please update the copyright years next time.
>> 
>> I've committed the patch,
>> 
>
> Here is a new patch. I have checked in a gcc patch which makes
> ".set noreorder" unnecessary even with "gcc -g".
>
> Thanks.

Thanks, committed,

Andreas
-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-02-08 16:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-02-06  2:02 PATCH: Not use branch likely on mips H . J . Lu
2002-02-07 10:38 ` Andreas Jaeger
2002-02-07 17:13   ` H . J . Lu
2002-02-08  8:00     ` Andreas Jaeger
2002-02-08 12:03       ` Maciej W. Rozycki
2002-02-08 16:15     ` Andreas Jaeger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox