This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Mined out of comp.std.c...


On Wed, Apr 24, 2002 at 11:51:17PM -0700, Zack Weinberg wrote:
> ... an interesting microoptimization.
> 
> The original post on comp.std.c is about whether
> 
> static int int_max (int a, int b) {
>     int d = (b - a);
>     return (b - d) & (d >> (CHAR_BIT*sizeof(int) - 1));
> }

This might work better :)

static int int_max (int a, int b) {
    int d = (b - a);
    return b - (d & (d >> (CHAR_BIT*sizeof(int) - 1)));
}

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]