Re: patch for 2.1.55 pre-1 minix/sysv/affs

Ralf Baechle (ralf@cobaltmicro.com)
Wed, 10 Sep 1997 13:51:20 -0700 (PDT)


> Bill Hawes wrote:
> > + if (minix_set_bit(j,bh->b_data))
> > + goto complain_and_out;
> [...]
> > +complain_and_out:
> > + printk("new_inode: bit already set");
> > +iput_and_out:
> > + iput(inode);
> > +out:
> > + return NULL;
>
> I hate this type of code, but for better cache-use, it is the faster way
> to write the code.....
>
> Would someone be interested in implementing
>
> #pragma rarely_used
>
> which would go inside an "if" statement, and cause gcc to do exactly
> what Bill is doing up there by hand....

For very good reasons GCC tries not to support #pragma.

> The new code would be:
>
> if (minix_set_bit(j,bh->b_data)) {
> #pragma rarely_used
> printk("new_inode: bit already set");
> iput(inode);
> return NULL;
> }
>
> gcc currently generates
>
> if not condition goto behind_if
> [code for the if clause]
> behind_if:
>
> which in case of the pragma should become
>
> if condition goto behind_everything_else
> [rest of function]
> ret
> behind_everything_else:
> [code for the if clause]
>
> I'd hope that this isn't too hard to implement.... :-)

Actually your answer already contains the solution to the problem:
Put the code for the common case into if. What GCC really lacks to
handle cases like this better is generating multiple copies of the
epilog code. Not to bad either because that makes code with a
small cache footprint.

Ralf