Re: early clobber for audio.c

Alexander Kjeldaas (astor@guardian.no)
Sun, 29 Mar 1998 19:43:42 +0200


--S5YaxWCcQjTEyOLp
Content-Type: text/plain; charset=us-ascii

On Sun, Mar 29, 1998 at 01:54:56PM +0200, Michael L. Galbraith wrote:
> Hi Alan,
>
> While tinkering with the new binutils (gas didn't like xlatb), I noticed
> that the inlined version of translate_bytes() is a candidate for
> conversion to early clobbers.
>
> I also noticed that if __volatile__ is omitted, xlat doesn't show up in
> the output at all. Is that an egcs bug, or is it (magically) possible to
> optimize translate_bytes() totally away?
>
> I _think_ that the following pseudocode_generator output is right.
>
> -Mike
>
> --- drivers/sound/audio.c.orig Wed Mar 18 18:54:39 1998
> +++ drivers/sound/audio.c Sun Mar 29 11:47:54 1998
> @@ -183,13 +183,15 @@
> {
> if (n > 0)
> {
> - __asm__("cld\n"
> + int __clobber0,__clobber1,__clobber2,__clobber3;
> + __asm__ __volatile__ ("cld\n"
> "1:\tlodsb\n\t"
> "xlatb\n\t"
> "stosb\n\t"
> - "loop 1b\n\t":
> - : "b"((long) table), "c"(n), "D"((long) buff), "S"((long) buff)
> - : "bx", "cx", "di", "si", "ax");
> + "loop 1b\n\t"
> + : "=&b"(__clobber0),"=&c"(__clobber1),"=&D"(__clobber2),"=&S"(__clobber3)
> + : "0"((long) table), "1"(n), "2"((long) buff), "3"((long) buff)
> + : "ax");
> }
> }
>

Use the attached patch instead. xlatb is a stupid, old, and slow
instruction. Besides, x86 assembly shouldn't be in this file in the
first place.

astor

-- 
 Alexander Kjeldaas, Guardian Networks AS, Trondheim, Norway
 http://www.guardian.no/

--S5YaxWCcQjTEyOLp Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="audio.patch"

--- audio.c.old Sun Mar 29 19:41:00 1998 +++ audio.c Sun Mar 29 19:41:23 1998 @@ -164,8 +164,6 @@ DMAbuf_release(dev, mode); } -#if defined(NO_INLINE_ASM) || !defined(i386) - static void translate_bytes(const unsigned char *table, unsigned char *buff, int n) { unsigned long i; @@ -176,24 +174,6 @@ for (i = 0; i < n; ++i) buff[i] = table[buff[i]]; } - -#else -extern inline void -translate_bytes(const void *table, void *buff, int n) -{ - if (n > 0) - { - __asm__("cld\n" - "1:\tlodsb\n\t" - "xlatb\n\t" - "stosb\n\t" - "loop 1b\n\t": - : "b"((long) table), "c"(n), "D"((long) buff), "S"((long) buff) - : "bx", "cx", "di", "si", "ax"); - } -} - -#endif int audio_write(int dev, struct file *file, const char *buf, int count) {

--S5YaxWCcQjTEyOLp--

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu