|
From: Nils on 7 May 2008 05:15 CBFalconer schrieb: > Nils wrote: >> tims next home schrieb: >> >>>>> x = "\00\02\01"[x]; >>>> You are insufficiently depraved. >>>> x = x["0\02\01"]; >>>> works, and is perfectly valid C. >>> Not when working on my team, it isn't:-) >> How about x = 4>>x > > After seeing the weird solutions I have decided that I AM > insufficiently depraved. These ridiculous solutions just never > occur to me. Am I missing something in the humour line? I use computed shifts on magic numbers in time-critical code to compress small lookup-tables into a single integer and index via shifts. That little trick works well if the talbe only has few indices and each element contains few bits. If all information fits into a machine-word you get a very cheap LUT. It saved my a** more than once. But I'm doing low-level graphic rendering functions and most of the stuff I write is in assembler. Saving a memory-access on the TI C64x+ DSP may give a factor2 performance win. I wouldn't like to see such code in a non-critical path as well. Nils
From: Walter Banks on 7 May 2008 08:03 CBFalconer wrote: > Nils wrote: > > tims next home schrieb: > > > >>>> x = "\00\02\01"[x]; > >>> > >>> You are insufficiently depraved. > >>> x = x["0\02\01"]; > >>> works, and is perfectly valid C. > >> > >> Not when working on my team, it isn't:-) > > > > How about x = 4>>x > > After seeing the weird solutions I have decided that I AM > insufficiently depraved. These ridiculous solutions just never > occur to me. Am I missing something in the humour line? ISA's have changed over the years. I was amazed at algorithmic opportunities that came with the first barrel shifter where shift by 1 and shift by x took the same execution time. Partially microcoded instruction sets that allow different operations on different execution cycles in a pipelined processor may be a nightmare to code but it only has to be right once. Regards -- Walter Banks Byte Craft Limited Tel. (519) 888-6911 http://www.bytecraft.com walter(a)bytecraft.com
First
|
Prev
|
Pages: 1 2 3 4 5 Prev: Inputs left floating at the very start Next: Microcontroller USB interface chip |