From c64fe299008a45e1bd3b90656d357a77edbb79c9 Mon Sep 17 00:00:00 2001 From: Andreas Zwinkau Date: Mon, 16 May 2011 13:56:08 +0200 Subject: [PATCH] Do not gcse unreachable code During global CSE we now ignore nodes in unreachable blocks, otherwise cse could pick the wrong representative node and use unreachable nodes in reachable code. --- ir/ir/iropt.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ir/ir/iropt.c b/ir/ir/iropt.c index 679410da3..ba62501a6 100644 --- a/ir/ir/iropt.c +++ b/ir/ir/iropt.c @@ -6129,6 +6129,16 @@ ir_node *identify_remember(ir_node *n) if (value_table == NULL) return n; + if (get_opt_global_cse()) { + /* do not remember unreachable nodes */ + if (get_irg_dom_state(irg) == dom_consistent && !is_Block(n)) { + ir_node *block = get_nodes_block(n); + if (get_Block_dom_depth(block) < 0) { + return n; + } + } + } + ir_normalize_node(n); /* lookup or insert in hash table with given hash key. */ nn = (ir_node*)pset_insert(value_table, n, ir_node_hash(n)); -- 2.20.1