Re: [patch/rfc 2/4] pcf875x I2C GPIO expander driver



Jean Delvare wrote:
!!(value & (1 << offset))
is more efficiently written
(value >> offset) & 1

... but not more efficiently implemented.

Your version requires code to do the shift on live data at runtime. David's version lets the compiler create the mask once, at compile-time.



b.g.

--
Bill Gatliff
bgat@xxxxxxxxxxxxxxx

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: [patch/rfc 2/4] pcf875x I2C GPIO expander driver
    ... Your version requires code to do the shift on live data at runtime. ... David's version lets the compiler create the mask once, ...
    (Linux-Kernel)
  • Re: Variadic functions calling variadic functions with the argument list, HLL bit shifts on LE proce
    ... There's no such thing as a "LE register" on most popular CPU ... shift is done on the value. ... >but one would hope that the shr for shift right instruction would ... The compiler needs to use assembler instructions. ...
    (comp.lang.c)
  • Re: Problem using Ada.Text_IO.Modular_IO
    ... to the generated assembly code. ... Using for shift left ... As for the "Interfaces" package the compiler uses if possible a machine ... Create a test program and compile it using either ...
    (comp.lang.ada)
  • Re: signed RSHIFT
    ... > It makes more work for the compiler (because it has to recognize the ... > idiom rather than just look up a name), ... there is no sane way to do this with repeated shift instructions. ... >>The alternative of defining primitives that correspond to many of the ...
    (comp.lang.forth)
  • Re: ARM7, DSP and mobile phone, how and why?
    ... >> And yes I've never heard of a compiler that didn't support signed right ... > magnitude machines. ... > ones complement machines. ... > rely on the results of signed shift. ...
    (comp.lang.c)