From c35ebd970d8eb6f6ef4f73e8a6a2084b1ed20a31 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Thu, 24 Jul 2003 15:12:30 +0000 Subject: [PATCH] Skip_nop removes chains and compacts cycles without increasing overall times of calling skip_nop. [r1562] --- ir/ir/irnode.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index 9baf74ee1..bf480c156 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -2161,6 +2161,7 @@ skip_Tuple (ir_node *node) { return node; } +#if 1 INLINE ir_node * skip_nop (ir_node *node) { /* don't assert node !!! */ @@ -2176,6 +2177,37 @@ skip_nop (ir_node *node) { return node; } } +#else + +/* This should compact Id-cycles to self-cycles. It has the same (or less?) complexity + than any other approach, as Id chains are resolved and all point to the real node, or + all id's are self loops. */ +INLINE ir_node * +skip_nop (ir_node *node) { + /* don't assert node !!! */ + + if (!get_opt_normalize()) return node; + + /* Don't use get_Id_pred: We get into an endless loop for + self-referencing Ids. */ + if (node && (node->op == op_Id) && (node != node->in[0+1])) { + ir_node *rem_pred = node->in[0+1]; + ir_node *res; + + assert (get_irn_arity (node) > 0); + + node->in[0+1] = node; + res = skip_nop(pred); + if (res->op == op_Id) /* self-loop */ return node; + + node->in[0+1] = res; + return res; + } else { + return node; + } +} + +#endif INLINE ir_node * skip_Id (ir_node *node) { -- 2.20.1