How to handle alias registers when parsing data flow using SSA form? (e.g. EAX / AX / AH / AL in x86)

For exmaple:

How to submit the following x86 to SSA Form :

xor  eax, eax
inc  ax

      

By introducing some pseudo functions, I get:

eax@1 = eax@0 ^ eax@0
ax@1 = LOWORD(eax@1)
al@1 = LOBYTE(ax@1)
ah@1 = HIBYTE(ax@1)
hax@1 = HIWORD(eax@1)

ax@2 = ax@1 + 1
eax@2 = MAKEDWORD(ax@2, HIWORD(eax@1))
al@2 = LOBYTE(ax@2)
ah@2 = HIBYTE(ax@2)

      

But I think this is too detailed

+2


a source to share


1 answer


Using your notation:

  • eax @ 0 = ... whatever it was before ...
  • eax @ 1 = 0
  • ax @ 2 = ax @ 1 + 1

Since eax contains ax, there is an implicit step between 2 and 3

  • eax @ 0 = ...
  • eax @ 1 = 0
  • ax @ 1 = 0 (since ax cannot be nonzero 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 rename so that it reads obviously , you will use a virtual register, not a real one):



  • --- deleted, eax is no longer relevant
  • ebx @ 0 = 0
  • bx @ 0 = 0
  • bx @ 1 = bx @ 0 + 1

Then you might notice that since step 3 is a constant function, so is step 4 (adding a constant to a constant) and squeezing two (i.e. constant bending)

  • - removed, eax is no longer relevant
  • ebx @ 0 = 0
  • bx @ 0 = 1

If the upper 16 bits of ebx don't dominate anything below, you can remove step 2 as well.

+2


a source







All Articles