Trial 7
Due on November 29th&nbs-06:00;11:59&nbs-06:00;PM (Not accepted late).

None yet!


For this trial, you should enhance the x64 codegen module of dmc such that the final code performs additional peephole optimization. In particular, you should ensure that the IRProgram::toX64 function performs the following optimizations:

  • Unconditional jumps to a successor instruction are disallowed
  • Subtraction by 0 or multiplication by 1 is eliminated
  • Subtraction by 1 uses the decrement instruction (decq)
  • Nop instructions are not emitted
You should ensure that the semantics of the program is preserved (i.e. adhere to the as-if principle). For the given optimizations, the main consideration is that if an instruction is eliminated, jumps should be forwarded. For example, if a nop is the target of a jump, the next (non-eliminated) instruction should instead be the target of that jump.


You may enhance your existing dmc source code such that when the argument is provided, the codegen obeys the above constraints.

Submit a complete source code tarball, including a makefile.