Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7022831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:37:58+00:00 2026-05-27T23:37:58+00:00

Being executed on modern processor (AMD Phenom II 1090T), how many clock ticks does

  • 0

Being executed on modern processor (AMD Phenom II 1090T), how many clock ticks does the following code consume more likely : 3 or 11?

label:  mov (%rsi), %rax
        adc %rax, (%rdx)
        lea 8(%rdx), %rdx
        lea 8(%rsi), %rsi
        dec %ecx
        jnz label

The problem is, when I execute many iterations of such code, results vary near 3 OR 11 ticks per iteration from time to time. And I can’t decide “who is who”.

UPD
According to Table of instruction latencies (PDF), my piece of code takes at least 10 clock cycles on AMD K10 microarchitecture. Therefore, impossible 3 ticks per iteration are caused by bugs in measurement.

SOLVED
@Atom noticed, that cycle frequency isn’t constant in modern processors. When I disabled in BIOS three options – Core Performance Boost, AMD C1E Support and AMD K8 Cool&Quiet Control, consumption of my “six instructions” stabilized on 3 clock ticks 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:37:59+00:00Added an answer on May 27, 2026 at 11:37 pm

    I won’t try to answer with certainty how many cycles (3 or 10) it will take to run each iteration, but I’ll explain how it might be possible to get 3 cycles per iteration.

    (Note that this is for processors in general and I make no references specific to AMD processors.)

    Key Concepts:

    • Out of Order Execution
    • Register Renaming

    Most modern (non-embedded) processors today are both super-scalar and out-of-order. Not only can execute multiple (independent) instructions in parallel, but they can re-order instructions to break dependencies and such.

    Let’s break down your example:

    label:
        mov (%rsi), %rax
        adc %rax, (%rdx)
        lea 8(%rdx), %rdx
        lea 8(%rsi), %rsi
        dec %ecx
        jnz label
    

    The first thing to notice is that the last 3 instructions before the branch are all independent:

        lea 8(%rdx), %rdx
        lea 8(%rsi), %rsi
        dec %ecx
    

    So it’s possible for a processor to execute all 3 of these in parallel.

    Another thing is this:

    adc %rax, (%rdx)
    lea 8(%rdx), %rdx
    

    There seems to be a dependency on rdx that prevents the two from running in parallel. But in reality, this is false dependency because the second instruction doesn’t actually
    depend on the output of the first instruction. Modern processors are able to rename the rdx register to allow these two instructions to be re-ordered or done in parallel.

    Same applies to the rsi register between:

    mov (%rsi), %rax
    lea 8(%rsi), %rsi
    

    So in the end, 3 cycles is (potentially) achievable as follows (this is just one of several possible orderings):

    1:   mov (%rsi), %rax        lea 8(%rdx), %rdx        lea 8(%rsi), %rsi
    2:   adc %rax, (%rdx)        dec %ecx
    3:   jnz label
    

    *Of course, I’m over-simplifying things for simplicity. In reality the latencies are probably longer and there’s overlap between different iterations of the loop.

    In any case, this could explain how it’s possible to get 3 cycles. As for why you sometimes get 10 cycles, there could be a ton of reasons for that: branch misprediction, some random pipeline bubble…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume that the following code is being executed by 10 threads. pthread_mutex_lock(&lock) Some trivial
The following code will result in the print statement being executed class C1(object): print
I'm trying to debug my code which is being executed from a unit test
Breakpoints are great when one knows where the code is being executed. However, I
Possible Duplicate: PHP code is not being executed (i can see it on source
I know that in the same directory where my code is being executed some
Does anyone have any problems with Page_Load being executed twice in Google Chrome? It's
I'm working on a bug where code is not always being executed before an
In the following, the return statement is being executed before the call to $.get()
The following SQL, upon being executed on an Oracle 9i server, yields the the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.