aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeddy <[email protected]>2014-04-29 23:54:14 +0800
committerTeddy <[email protected]>2014-04-29 23:54:14 +0800
commit07de7509afa048badbdd1c4c3c9a4af407e7041c (patch)
tree1970f8f8b63567e228d1099a0cd3803fe5c8bc58
parent042d8cf2f62b92abc8b14ab88a09c875a265d585 (diff)
...
-rw-r--r--ssa.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/ssa.c b/ssa.c
index be7e4f0..bfc27a7 100644
--- a/ssa.c
+++ b/ssa.c
@@ -469,12 +469,26 @@ COpr_t ssa_exp_(CNode *p, CBlock_t cur, CInst_t lval, CBlock_t succ) {
{
inst->src1 = ssa_exp_(p->chd->next, cur, NULL, succ);
ssa_exp_(p->chd, cur, inst, succ);
- cblock_append(cur, inst);
if (inst->op == MOVE)
- return inst->dest;
+ {
+ CInst_t last = cblock_getback(cur);
+ if (last && last->dest->kind == TMP)
+ {
+ free(last->dest);
+ last->dest = inst->dest;
+ free(inst);
+ return last->dest;
+ }
+ else
+ {
+ cblock_append(cur, inst);
+ return inst->dest;
+ }
+ }
else
{
CInst_t tins = NEW(CInst);
+ cblock_append(cur, inst);
tins->op = ARR;
tins->src1 = inst->dest; /* base */
tins->src2 = inst->src2; /* displacement */