andreas-abel / uiCA

uops.info Code Analyzer
GNU Affero General Public License v3.0
230 stars 16 forks source link

Strange WAW/WAR-dependence edge in dependency graph #21

Closed amonakov closed 1 year ago

amonakov commented 1 year ago

For the following testcase (short link: https://bit.ly/3v1QfWV )

loop:
add rax, [rsi]
adc rax, [rsi]
dec rcx
jnz loop

There's the expected critical path over RAX updates, plus unexpected two-cycle critical path that goes over the carry flag:

b41d13c23d9d4444ad7886107285db42_dep

I'm surprised to see the backward edge from CF to the first instruction there.

andreas-abel commented 1 year ago

The add instruction reads RAX and writes the carry flag (this is the forward edge); the adc instruction reads the carry flag and writes RAX (this is the backward edge).

amonakov commented 1 year ago

Ah, sorry... Thanks for the explanation. I take it the items in a rectangle correspond just to instruction inputs (and outputs are not explicitly visible)?

Out of curiosity, have you explored other ways to visualize the dependency graph?

andreas-abel commented 1 year ago

I take it the items in a rectangle correspond just to instruction inputs (and outputs are not explicitly visible)?

Yes, they are only implicitly visible as the input to the next instruction (and outputs that are never read are ignored, as they are not really relevant in this context).

Out of curiosity, have you explored other ways to visualize the dependency graph?

I have tried a few ways, and this was the best I could find so far. But there is certainly room for improvement.