On Mon, Feb 03, 2003 at 04:36:01PM +0100, Erik Mouw wrote: > On Mon, Feb 03, 2003 at 04:46:28PM +0200, Gilad Benjamini wrote: > > AFAIK, embedded assembly code (__asm) can not be optimized by the > > compiler. > > It can't be optimised away, but register and memory usage can be > optimised. No. For assembly source, nothing can be optimized. For inline assembly, the inline assembly itself can't be optimized, but some things can be left on gcc to decide (read optimize). > > I heard through the grapevine that you can embed a single assembly > > instruction, > > using a "__" prefix, and in this case the compiler CAN optimize. The > > code. > > Is this correct ? > > No. Partialy. There is no difference between single and multiple instruction inline assembly. > > What's the exact syntax ? > > __asm__ ( "asm code" : "input variables" : "output variables" : "clobber" ); While assembly can't be optimized, this syntax allows gcc to optimize the code around the assembly. It allows gcc to minimize number of stores and loads needed around the assembly bit. > > Where is this documented ? > > The gcc info pages (try tkinfo or pinfo, they're better info readers > than info). Also be sure to check the links section on > kernelnewbies.org, we have a couple of links to inline assembly. > > BIG FAT WARNING: Try to avoid assembly! It makes your code non-portable > and hard to maintain! And a notice: you don't need gcc to optimize assembly, because you only write code in assembly if you already optimized it better than gcc can ever do. ------------------------------------------------------------------------------- Jan 'Bulb' Hudec <bulb@ucw.cz> -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/