aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeddy <ted.sybil@gmail.com>2014-05-07 13:42:16 +0800
committerTeddy <ted.sybil@gmail.com>2014-05-07 13:42:16 +0800
commit99e4b1f46c868dad37b6a9c30fd1210cb041a576 (patch)
tree0affa4459d9bcc37b388bceb255993acb42b22e3
parent955a1c73f2cfd97058f5d850830386e2d3becabc (diff)
fix bug in subexp opt
-rw-r--r--ssa.c24
-rw-r--r--ssa.h1
2 files changed, 23 insertions, 2 deletions
diff --git a/ssa.c b/ssa.c
index ff7c0a7..af1311f 100644
--- a/ssa.c
+++ b/ssa.c
@@ -2493,6 +2493,23 @@ CExpMap_t cexpmap_create(void) {
return res;
}
+CExpMap_t cexpmap_dup(CExpMap_t cem) {
+ int i;
+ CExpMap_t res = cexpmap_create();
+ for (i = 0; i < MAX_TABLE_SIZE; i++)
+ {
+ CENode *p, *t;
+ for (p = cem->head[i]; p; p = p->next)
+ {
+ t = NEW(CENode);
+ t->exp = p->exp;
+ t->next = res->head[i];
+ res->head[i] = t;
+ }
+ }
+ return res;
+}
+
int cexpmap_comp(CInst_t exp1, CInst_t exp2) {
if (exp1->op != exp2->op) return 0;
if (!copr_eq(exp1->src1, exp2->src1)) return 0;
@@ -2581,8 +2598,11 @@ void subexp_elimination_(CBlock_t b, CExpMap_t cem) {
}
}
for (e = dtree.head[b->id]; e; e = e->next)
- subexp_elimination_(e->to, cem);
- cexpmap_clear(cem);
+ {
+ CExpMap_t scem = cexpmap_dup(cem);
+ subexp_elimination_(e->to, scem);
+ cexpmap_destroy(scem);
+ }
}
void subexp_elimination(void) {
diff --git a/ssa.h b/ssa.h
index 68ea774..2ad86cd 100644
--- a/ssa.h
+++ b/ssa.h
@@ -137,6 +137,7 @@ typedef struct CExpMap {
typedef CExpMap *CExpMap_t;
CExpMap_t cexpmap_create(void);
+CExpMap_t cexpmap_dup(CExpMap_t cem);
unsigned int cexpmap_hash(CInst_t exp);
int cexpmap_comp(CInst_t exp1, CInst_t exp2);
void cexpmap_insert(CExpMap_t cem, CInst_t exp);