From bd6cd038d82f31ee86aa5c656c4181cd19e9070d Mon Sep 17 00:00:00 2001 From: Teddy Date: Tue, 6 May 2014 10:58:07 +0800 Subject: correct subexp opt --- lib.s | 6 ++---- ssa.c | 12 +++++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib.s b/lib.s index e57735c..72b138c 100644 --- a/lib.s +++ b/lib.s @@ -64,14 +64,12 @@ __L10: # if not (t14) goto __L12 bne $10, 0, __L12 # len_11 = 1 - li $2, 1 - move $11 $2 + li $11, 1 # goto __L15 j __L15 __L12: # len_8 = 0 - li $2, 0 - move $11 $2 + li $11, 0 # goto __L14 j __L14 __L13: diff --git a/ssa.c b/ssa.c index b6cf00b..d7b3c3b 100644 --- a/ssa.c +++ b/ssa.c @@ -1912,15 +1912,14 @@ void init_def(void) { opr->spill = cinterv_repr(opr); } /* coalescing */ - /* for (p = entry; p; p = p->next) { CInst_t i, ih = p->insts; for (i = ih->next; i != ih; i = i->next) - if (i->op == MOVE && i->dest->kind == TMP && i->src1->kind == TMP) + if (i->op == MOVE && i->dest->kind == TMP && + (i->src1->kind == TMP || i->src1->kind == VAR)) cinterv_union(i->dest, i->src1); } - */ } void print_intervals(void) { @@ -2452,19 +2451,22 @@ void subexp_elimination_(CBlock_t b, CExpMap_t cem) { case SHL: case SHR: case AND: case XOR: case OR: case NOR: case EQ: case NE: case LT: case GT: case LE: case GE: case NEG: - cexpmap_insert(cem, i); + if (i->dest->kind == TMP) cexpmap_insert(cem, i); break; default: ; } } } - cexpmap_clear(cem); for (e = dtree.head[b->id]; e; e = e->next) subexp_elimination_(e->to, cem); + cexpmap_clear(cem); } void subexp_elimination(void) { CExpMap_t cem = cexpmap_create(); +/* int i; + for (i = bcnt - 1; i >= 0; i--) + */ subexp_elimination_(entry, cem); cexpmap_destroy(cem); } -- cgit v1.2.3-70-g09d2