PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

instruction cycles

I've just discovered VTune (not discovered, it's just that I have some functions I'd like to optimize and I've seens it's really a useful tool, probably the best intel tool ever done ;) )

I have a cycle problem. I have this code:

Code:

ADD r0,r0,r1
MOV r1,r6,lsr #24
ADD r0,r0,r1,lsl #9 ; r1 not ready!
ldrh r0,[r0]


vtune says r1 is not ready in the third instruction. I suppose it's cause due to the lsr #24 which needs an extra cycle.

But why it is not complaining about 4th instruction? I though r0 in the 3rd instruction should need 2 cycles to be ready due to the shift, but vtune says "Exec=1" (1 cycle to get results), while says "Exec=2".

is add r0,r0,r1,lsl #9 really giving the result to ldrh in 1 cycle (no stall), or it's ldrh which needs 2 cycles to fetch r0?

TIA
Kak
I suppose it's cause due to the lsr #24 which needs an extra cycle.


Correct - see page 167 of the XScale core developer's manual (giving one issue, 2 latency). The LDR should also stall due to the latency of the add (unless I've missed something).
'add' has no lantency. shifting has when the register is updated before the instruction (like in your example). so you should not have problem after 'add'.
Arrgh, I misread the manual.

Here's the relevant text:

If the next instruction needs to use the result of the data processing for a shift by immediate or as Rn in a QDADD or QDSUB, one extra cycle of result latency is added to the number listed.


So, the MOV stalls (one issue, two latency) 'cos the ADD wants to use a result from the MOV in its shift operator. The LDR doesn't stall 'cos it's not using a shift.