lkml.org 
[lkml]   [2001]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: * 4 converted to << 2 for networking code
    Date
    Followup to:  <20010110161146.A3252@unthought.net>
    By author: =?iso-8859-1?Q?Jakob_=D8stergaard?= <jakob@unthought.net>
    In newsgroup: linux.dev.kernel
    >
    > On most processors <<2 is slower than *4.
    >

    That's a funny statement. Which processors do you include in "most"?
    That has not been my experience.

    > It's outright stupid to write <<2 when we mean *4 in order to optimize for one out of a
    > gazillion supported architectures - even more so when the compiler
    > for the one CPU where <<2 is faster, will actually generate a shift
    > instead of a multiply as a part of the standard optimization.
    >
    > One question for the GCC people: Will gcc change <<2 to *4 on other
    > architectures ? If so, then my case is not quite as strong of course.
    >

    gcc should consider the statements equivalent, and generate whichever
    pattern is preferred. On an i386 that may mean take a pattern such as

    foo = (bar << 2) + quux;

    ... and generate ...

    lea ecx,[esi*4+ebx]

    -hpa
    --
    <hpa@transmeta.com> at work, <hpa@zytor.com> in private!
    "Unix gives you enough rope to shoot yourself in the foot."
    http://www.zytor.com/~hpa/puzzle.txt
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:28    [W:0.035 / U:206.112 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site