Is there any standard way for converting an (any) equation into bit-shift operations?
By this I mean converting any thing that is not a + or - into bit-shifts, so the end equation contains only the operands <<, >>, +, and -. This is in the interest of making formulas less processor intensive.
Obviously these resultant equations will only be approximations, giving better accuracy with the more orders considered (first-order, second-order e.t.c).
I have scoured the web for any information on this but can't find any, except for stuff on specific formulas (sin, cos, inv e.t.c).
I was envisioning something like a polynomial or Taylor's expansion procedure, and then converting that to bit-shift operations.
Just because you're reducing something to simpler instructions, doesn't mean they're going to execute faster or be less intensive in some way. While you may be able to reduce many things to a reduced subset of operations, you're probably going to need many many more operations to accomplish the same task. A processor can only execute so many operations per second, and you're going to run into that first.
Generally when trying to optimize something at a low level, you're trying to make use of the far more complex opcodes so that you need fewer of them. As an example, you can perform multiplication by doing many ADD instructions. But, for anything other than the most trivial of examples, it's going to take substantially more ADDs than the single MUL opcode that it took, and take far longer to execute.
Getting back to your actual question though... Totally ignoring efficiency, you can calculate anything as long as the instruction set you have is Turing Complete. You actually can calculate anything using a single instruction, if you're careful how you choose that instruction. I don't believe there's any general purpose way of saying "Convert any arbitrary algorithm into using only these instructions", that's generally the job of a compiler writer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With