![]() |
|
|
#34 | ||
|
Apr 2003
Berlin, Germany
16916 Posts |
Quote:
Quote:
Just look at this pseudo code (for a risc like architectures like the execution cores of x86 CPUs): [code:1]// format is instruction dest, source fpload r0, [x] fpload r1, [const_4] fpmov r2, r0 ;we need it later again fpmul r0, r0 ; x² fpmul r2, r1 ; 4x fpadd r0, r2 ; x²+4x fpstore [a], r0 [/code:1] With 3 operands it would maybe look like this: [code:1]// format is instruction dest, source1, source2 fpload r0, [x] fpload r1, [const_4] fpmul r2, r0, r0 ; x² fpmul r1, r0, r1 ; 4x fpadd r3, r1, r2 ; x²+4x fpstore [a], r3 [/code:1] We saved one instruction in this simple calculation. But if you look at complex SSE2 or also x87 code you'll see a lot of shuffling, moving and saving registers (that they don't get destroyed all the time). While x86 CPUs have to move and save, the other CPUs (Alpha, Power, even G5) continue to calculate. DDB |
||
|
|
|
|
|
#35 |
|
Aug 2002
101 Posts |
I got a better compiler for a=x²+4x:
// format is instruction dest, source fpload r0, [x] fpmov r1, r0 ;we need it later again fpadd r0, [const_4] ;x+4 fpmul r1, r0 ; x²+4x fpstore [a], r1 Moving data between regs is the fastest instruction. Cant compare to fpmul. Load/Store memory is more than one instruction usually. That further brings down the weight of fpmov. 2 operand vs 3 operand is a long debate. There isnt any clear winner. |
|
|
|
|
|
#36 | |
|
Apr 2003
Berlin, Germany
192 Posts |
Quote:
At least by using a simple adressing mode the load/store can be handled easily by the hardware. IMO the advantage of 3 operand instructions is, that you may use a different destination register or just one of the sources - what fits best for the algorithm, while with 2 operands you are always required to overwrite one of the sources. And the disadvantage is, that the opcode needs additional bits for adressing the third register. DDB |
|
|
|
|
![]() |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Impact of AI | xilman | Lounge | 19 | 2017-01-26 16:03 |
| GPUs impact on TF | petrw1 | GPU Computing | 0 | 2013-01-06 03:23 |
| GPU TF work and its impact on P-1 | davieddy | Lounge | 161 | 2011-08-09 10:27 |
| Another Impact on Jupiter | Spherical Cow | Astronomy | 24 | 2009-08-12 19:32 |
| P4 Prescott - 31 Stage Pipeline ? Bad news for Prime95? | Angular | Hardware | 18 | 2004-11-15 07:04 |