From df56475fd7eb829450603d20e3a42f9c32915fd2 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Wed, 13 Jun 2007 14:38:10 +0000 Subject: [PATCH] Optimize SubInt(ConvInt(aP), ConvInt(bP)) into SubInt(aP,bP) [r14466] --- ir/ir/iropt.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/ir/ir/iropt.c b/ir/ir/iropt.c index fb966c06e..3bd393c21 100644 --- a/ir/ir/iropt.c +++ b/ir/ir/iropt.c @@ -962,6 +962,7 @@ static ir_node *equivalent_node_Sub(ir_node *n) { a = get_Sub_left(n); b = get_Sub_right(n); +restart: /* Beware: modes might be different */ if (classify_tarval(value_of(b)) == TV_CLASSIFY_NULL) { @@ -970,7 +971,7 @@ static ir_node *equivalent_node_Sub(ir_node *n) { DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_NEUTRAL_0); } - } else if (get_irn_op(a) == op_Add) { + } else if (is_Add(a)) { if (mode_wrap_around(mode)) { ir_node *left = get_Add_left(a); ir_node *right = get_Add_right(a); @@ -987,6 +988,27 @@ static ir_node *equivalent_node_Sub(ir_node *n) { } } } + } else if (mode_is_int(mode) && is_Conv(a) && is_Conv(b)) { + ir_mode *mode = get_irn_mode(a); + + if (mode == get_irn_mode(b)) { + ir_mode *ma, *mb; + + a = get_Conv_op(a); + b = get_Conv_op(b); + + /* check if it's allowed to skip the conv */ + ma = get_irn_mode(a); + mb = get_irn_mode(b); + + if (mode_is_reference(ma) && mode_is_reference(mb)) { + /* SubInt(ConvInt(aP), ConvInt(bP)) -> SubInt(aP,bP) */ + set_Sub_left(n, a); + set_Sub_right(n, b); + + goto restart; + } + } } return n; } /* equivalent_node_Sub */ -- 2.20.1