Other Strength Reduction Operations
-
- This material is disputed. It is better described as peephole optimizations and instruction assignment.
Operator strength reduction uses mathematical identities to replace slow math operations with faster operations. The benefits depend on the target CPU and sometimes on the surrounding code (which can affect the availability of other functional units within the CPU).
- replacing integer division or multiplication by a power of 2 with an arithmetic shift or logical shift
- replacing integer multiplication by a constant with a combination of shifts, adds or subtracts
- replacing integer division by a constant with a multiplication, taking advantage of the limited range of machine integers.
| original calculation | replacement calculation |
|---|---|
| y = x / 8 | y = x >> 3 |
| y = x * 64 | y = x << 6 |
| y = x * 2 | y = x << 1 |
| y = x * 15 | y = (x << 4) - x |
Read more about this topic: Strength Reduction
Famous quotes containing the words strength, reduction and/or operations:
“These are days when no one should rely unduly on his competence. Strength lies in improvisation. All the decisive blows are struck left-handed.”
—Walter Benjamin (18921940)
“The reduction of nuclear arsenals and the removal of the threat of worldwide nuclear destruction is a measure, in my judgment, of the power and strength of a great nation.”
—Jimmy Carter (James Earl Carter, Jr.)
“A sociosphere of contact, control, persuasion and dissuasion, of exhibitions of inhibitions in massive or homeopathic doses...: this is obscenity. All structures turned inside out and exhibited, all operations rendered visible. In America this goes all the way from the bewildering network of aerial telephone and electric wires ... to the concrete multiplication of all the bodily functions in the home, the litany of ingredients on the tiniest can of food, the exhibition of income or IQ.”
—Jean Baudrillard (b. 1929)