aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-03-29 01:33:34 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-02-24 10:49:15 +0100
commitc5ba883e6ac47381f8112ed33f22a931a79ac517 (patch)
tree7a945cb1ab8810188e16cb8785f63f4799b0ec49
parentadc4d32ef551907128637600a98ba28153ef79d8 (diff)
downloadsparse-dev-c5ba883e6ac47381f8112ed33f22a931a79ac517.tar.gz
cse: untangle simplification & hashing
Currently, the simplification of individual instructions is done at the beginnig of the function doing the hashing for CSE. Separate the two help a little bit to understand the code there and making any changes if needed. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--cse.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/cse.c b/cse.c
index 53855680..5a5cea17 100644
--- a/cse.c
+++ b/cse.c
@@ -35,16 +35,10 @@ static int phi_compare(pseudo_t phi1, pseudo_t phi2)
}
-static void clean_up_one_instruction(struct basic_block *bb, struct instruction *insn)
+static void cse_collect(struct instruction *insn)
{
unsigned long hash;
- if (!insn->bb)
- return;
- assert(insn->bb == bb);
- repeat_phase |= simplify_instruction(insn);
- if (!insn->bb)
- return;
hash = (insn->opcode << 3) + (insn->size >> 3);
switch (insn->opcode) {
case OP_SEL:
@@ -144,7 +138,11 @@ static void clean_up_insns(struct entrypoint *ep)
FOR_EACH_PTR(ep->bbs, bb) {
struct instruction *insn;
FOR_EACH_PTR(bb->insns, insn) {
- clean_up_one_instruction(bb, insn);
+ repeat_phase |= simplify_instruction(insn);
+ if (!insn->bb)
+ continue;
+ assert(insn->bb == bb);
+ cse_collect(insn);
} END_FOR_EACH_PTR(insn);
} END_FOR_EACH_PTR(bb);
}