0

Upon using Intel's Vtune tool, I notice that the

movsxd rax, edx 

instruction is taking quite some time to execute. I understand that we access both 32 bit and 64 bit registers in this assembly code but is it expected to take a long time to execute? Thanks!

Machine: Intel's Cascade Lake (Core i9-10980XE)

--- Edit ----
Added a screenshot of the assembly to provide more context.

Block 1                                 6,735,000,000
push rbx                                210,000,000
push rsi                                30,000,000
push r14                                30,000,000
sub rsp, 0x50                           120,000,000
mov r14, rcx    
nop 
lock inc dword ptr [rsp+0x78]   
movsxd rax, edx                         5,985,000,000
nop 
mov rbx, qword ptr [rcx+rax*8+0x8]  0
lea rsi, ptr [rcx+rax*8]                360,000,000
test rbx, rbx   
jnz 0x14900fdff <Block 3>
Vignesh
  • 1
  • 2
  • 2
    It's not slow itself (https://uops.info/ - 1 cycle latency for any ALU port). Presumably it's just the instruction stuck waiting for an input that an earlier instruction is slow to produce. You didn't show any context so we can't say any more. – Peter Cordes Aug 30 '23 at 22:06
  • @PeterCordes A couple of follow-up questions 1. In Vtune, is it fair to say that the instruction taking the longest time is at the head of the ROB in most cases when sampled? 2. I edited the post to provide more context. Thanks! – Vignesh Aug 31 '23 at 21:55
  • Yes, I think so. As I wrote in the linked duplicate, I think Intel CPUs let the oldest instruction in the ROB retire before handling an interrupt (perhaps to ensure forward progress if an IRQ is constantly asserted?) So probably the `lock inc` was at the head of the ROB for a long time; we expect it to be slow inherently, and because it has to wait for the store buffer to drain before it can exec and retire. So it's not rare for the "cycles" event counter to roll over and raise an interrupt. Which is handled *after* `lock inc` retires, "blaming" the cheap and independent `movsxd`. – Peter Cordes Aug 31 '23 at 22:16

0 Answers0