public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: vda <vda@port.imtp.ilyichevsk.odessa.ua>
To: Jan-Benedict Glaw <jbglaw@microdata-pos.de>,
	linux-kernel@vger.kernel.org
Subject: Re: xchg and GCC's optimisation:-(
Date: Mon, 17 Dec 2001 15:33:47 -0200	[thread overview]
Message-ID: <01121715334709.02146@manta> (raw)
In-Reply-To: <20011217134526.A31801@microdata-pos.de>
In-Reply-To: <20011217134526.A31801@microdata-pos.de>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="PT 154", Size: 1241 bytes --]

On Monday 17 December 2001 10:45, Jan-Benedict Glaw wrote:

> void free_dma(unsigned int dmanr)
> {
>         if (dmanr >= MAX_DMA_CHANNELS) {
>                 printk("Trying to free DMA%d\n", dmanr);
>                 return;
>         }
>
>         if (xchg(&dma_chan_busy[dmanr].lock, 0) == 0) {
> /* ERROR */     printk("Trying to free free DMA%d\n", dmanr);
>                 return;
>         }
>
> } /* free_dma */
>
> Including a real_printk() at the line marked with ERROR will
> result in:
[snip]
> ...which is fine and contains the needed xchg call. However,
> substituting the printk() with "do {} while (0)" above,
> the "if" path seems to be completely removed by the optimizer:
>
> 00000088 <free_dma>:
>   88:   c3                      ret
>   89:   8d b4 26 00 00 00 00    lea    0x0(%esi,1),%esi
>
>
> I've looked at ./include/asm-i386/system.h which does some black
> magic with it, and I don't really understand that. However, the
> result is that the xchg gets optimized away, rendering at least
> the floppy module unuseable:-(

There is a comment that asm is not 100% valid.
My GCC 3.0.1 does not produce buggy code, guess why?
It does _not_ inline __xchg() even at -O99!

So much of compiler improvement  8-(
--
vda

      parent reply	other threads:[~2001-12-17 13:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-17 12:45 xchg and GCC's optimisation:-( Jan-Benedict Glaw
2001-12-17 13:18 ` Momchil Velikov
2001-12-17 13:55   ` Jan-Benedict Glaw
2001-12-17 17:33 ` vda [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=01121715334709.02146@manta \
    --to=vda@port.imtp.ilyichevsk.odessa.ua \
    --cc=jbglaw@microdata-pos.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox