/** * Checks whether node high is a sign extension of low. */ static bool is_sign_extend(ir_node *low, ir_node *high) { if (is_Shrs(high)) { ir_node *high_r = get_Shrs_right(high); if (!is_Const(high_r)) return false; ir_tarval *shift_count = get_Const_tarval(high_r); if (!tarval_is_long(shift_count)) return false; if (get_tarval_long(shift_count) != 31) return false; ir_node *high_l = get_Shrs_left(high); if (is_Conv(low) && get_Conv_op(low) == high_l) return true; if (is_Conv(high_l) && get_Conv_op(high_l) == low) return true; } else if (is_Const(low) && is_Const(high)) { ir_tarval *tl = get_Const_tarval(low); ir_tarval *th = get_Const_tarval(high); if (tarval_is_long(th) && tarval_is_long(tl)) { long l = get_tarval_long(tl); long h = get_tarval_long(th); return (h == 0 && l >= 0) || (h == -1 && l < 0); } } return false; }
void ConvHandler::cleanUp(Node node) { if (is_Conv(node)) { Node child = node.getChild(0); if (/*is_Conv(child) && */ node.getMode() == child.getMode()) replaceNode(node, child); else if (is_Const(child)) replaceNode(node, new_r_Const_long(irg, node.getMode(), child.getTarval().getLong())); else if (is_Conv(child)) set_irn_n(node, 0, child.getChild(0)); } }