Re: xor as a lazy comparison

From: Paulo Marques (pmarques_at_grupopie.com)
Date: 07/25/05

  • Next message: Dmitry Torokhov: "Re: Problem with Asus P4C800-DX and P4 -Northwood-"
    Date:	Mon, 25 Jul 2005 20:23:17 +0100
    To: Lee Revell <rlrevell@joe-job.com>
    
    

    Lee Revell wrote:
    > On Mon, 2005-07-25 at 13:55 -0400, Steven Rostedt wrote:
    >
    >>Doesn't matter. The cycles saved for old compilers is not rational to
    >>have obfuscated code.
    >
    > Where do we draw the line with this? Is x *= 2 preferable to x <<= 2 as
    > well?

    I guess this depends on what you logically want to do. If the problem
    requires you to shift some value N bits, then you should use a shift
    operation.

    If what you want is to multiply a value by a certain ammount, you should
    just use a multiplication.

    Using a shift to perform the multiplication should be left to the
    compiler IMHO.

    The proof that the shift is not so clear is that even you got the shift
    wrong in your own example ;)

    -- 
    Paulo Marques - www.grupopie.com
    It is a mistake to think you can solve any major problems
    just with potatoes.
    Douglas Adams
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: Dmitry Torokhov: "Re: Problem with Asus P4C800-DX and P4 -Northwood-"

    Relevant Pages

    • Re: Is Fortran still faster than C for math applications?
      ... >>IAND corresponds to the x86 shift and rotate instructions that ... >>take the shift count mod 32. ... Without the IAND the compilers ... I have always assumed in my Alpha assembly code. ...
      (comp.lang.fortran)
    • Re: ARM7, DSP and mobile phone, how and why?
      ... > is portable across many compilers and architectures with little effort. ... magnitude machines. ... rely on the results of signed shift. ...
      (comp.lang.c)
    • Re: [Linux-fbdev-devel] [PATCH] fbdev: fix fillrect for 24bpp modes
      ... Krzysztof Helt wrote: ... Michal Januszewski wrote: ... Most compilers will optimize it away into ... a simple shift because the bits has only one bit set ...
      (Linux-Kernel)
    • Re: find out the problem
      ... >> equal to the width of the promoted left operand, ... There are a number of assembly languages where the shift count can ... Compilers typically take the shift count, stuff it in a register, ... shift of N bits of an int or long to the ...
      (comp.lang.c)
    • Re: kernel/microcode.c error from new 64bit code
      ... higher precedence than the shift, so on i386 ... You might as well write zero if that's what you mean. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)