Using your notation:
- eax@0 = ... whatever it was before here ...
- eax@1 = 0
- ax@2 = ax@1 + 1
Because eax contains ax, there's an implicit step in between 2 and 3
- eax@0 = ...
- eax@1 = 0
- ax@1 = 0 (because ax cannot be non-zero if eax is zero)
- ax@2 = ax@1 + 1
Step 2 because any number xor'ed with itself is 0... eax@0 is dead at that point, and thus eax@1 can be renamed (using ebx as renaming so it's readable; obviously you would use a virtual register, not a real one):
- --- deleted, eax no longer relevant
- ebx@0 = 0
- bx@0 = 0
- bx@1 = bx@0 + 1
You could then note that because step 3 is a constant function, so is step 4 (adding a constant to a constant) and compress the two together (i.e. constant folding)
- -- deleted, eax no longer relevant
- ebx@0 = 0
- bx@0 = 1
If the upper 16 bits of ebx don't dominate anything below this, you could also delete step 2.