Messages in this thread |  | | Subject | Re: * 4 converted to << 2 for networking code | From | Chris Jones <> | Date | 10 Jan 2001 10:31:34 -0500 |
| |
Mike Harrold <mharrold@cas.org> writes:
[...]
My feeling is that it shouldn't matter if you use <<2 or *4 even if the compiler optimises - one would hope that the compiler would optimise to the fastest in both directions.
I agree this should be left to the compiler. The programmer should write *4 when multiplying by 4 and <<2 when shifting left by 2. In the case that sparked this (converting counts of 32 bit units to counts of octets), multiplication is the proper conversion operation.
(If performance is truly critical AND profiling shows that writing <<2 instead of *4 makes a significant difference, doing the shift might be called for. I hardly believe that's the case here, and the fact that the code has to run on several architectures and be compiled by various compilers makes it less likely that this change is a clearcut win.)
- 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/
|  |