A walkthrough of how a dependence DAG over a straight-line block decides which instruction orders are legal, and how a scheduler picks among them. Includes a property test that every topological order of a random program computes the same result as program order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
18 lines
743 B
ArmAsm
18 lines
743 B
ArmAsm
; r10 points at a struct {x, y, z, w}; r11 points somewhere else.
|
|
; p->z = p->x*p->x + p->y*p->y
|
|
; q = 3 * p->w
|
|
; r5 = q < p->z
|
|
; *r11 = q
|
|
load r1, [r10] ; x
|
|
load r2, [r10+1] ; y
|
|
mul r3, r1, r1 ; x*x (waits on the load)
|
|
mul r4, r2, r2 ; y*y
|
|
add r3, r3, r4 ; x*x + y*y (waits on the mul)
|
|
store r3, [r10+2] ; p->z
|
|
load r1, [r10+3] ; w: reuses r1 -> WAR with the first mul
|
|
li r2, 3 ; reuses r2 -> WAR with the second mul
|
|
mul r1, r1, r2 ; q = 3w
|
|
cmp r1, r3 ; writes the hidden flags register
|
|
setlt r5 ; reads it
|
|
store r1, [r11] ; r11 may alias r10: ordered after every access
|