def propagand_ops(codes): for i, c in enumerate(codes): if c.code_t == tac.BINARY and not c.immp('y') and c.immp('z'): if c.z == 0 and c.op in ['+', '-']: # + 0 / - 0: throw codes[i] = tac.assign(c.x, c.y) elif c.z == 1 and c.op in ['*', '/']: codes[i] = tac.assign(c.x, c.y) elif c.z == 0 and c.op == '*': codes[i] = tac.assign(c.x, 0) elif c.z == 0 and c.op == '/': raise CompileTimeError, 'divide by zero' return make_optim(False)
def case0_run(codes, argl, argd): for i in argd['opt_idx']: codes[i] = tac.assign(codes[i].x, codes[i].fold())