pfalcon / ScratchABlock

Yet another crippled decompiler project
https://github.com/EiNSTeiN-/decompiler/issues/9#issuecomment-103221200
GNU General Public License v3.0
102 stars 23 forks source link

Cases where propagation should be limited/reverted #11

Open pfalcon opened 6 years ago

pfalcon commented 6 years ago

040-bzero:

    $a6 = $a2_0;
    if (cond) {
      $a6 = $a2_0 + 0x1;
    }

Here, it would be better to have:

    $a6 = $a2_0;
    if (cond) {
      $a6 += 0x1;
    }
pfalcon commented 6 years ago

040-bzero:

      do {
        *(u8*)$a6 = 0x0;
        *(u8*)($a6 + 0x1) = 0x0;
        $a6 += 0x2;
      } while ($a6 != $a2_0 + $a3_0);

Condition in while. Fairly speaking, for decompilation understanding that's probably better than having a test against a variable with meaningless name. But for reusing decompiled output, constant subexpressions should be hoisted out of the loop for efficiency. (On the other hand, an optimizing compiler would do that itself.)