X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fopt_confirms.c;h=4792d4255584638d6dc7b02bd2a0767e758c06e0;hb=9e11e8bbbe517056f03a823a564f91793920a078;hp=28e0ef7d5588b7ad8c1738481bfd5d684fefb1f2;hpb=8829c3217ea4a00be8af74a260f8ca79367361f2;p=libfirm diff --git a/ir/opt/opt_confirms.c b/ir/opt/opt_confirms.c index 28e0ef7d5..4792d4255 100644 --- a/ir/opt/opt_confirms.c +++ b/ir/opt/opt_confirms.c @@ -97,7 +97,7 @@ static tarval *compare_iv_dbg(const interval_t *l_iv, const interval_t *r_iv, pn * This is a often needed case, so we handle here Confirm * nodes too. */ -int value_not_zero(ir_node *n, ir_node **confirm) { +int value_not_zero(const ir_node *n, ir_node_cnst_ptr *confirm) { #define RET_ON(x) if (x) { *confirm = n; return 1; }; break tarval *tv; @@ -175,19 +175,21 @@ int value_not_zero(ir_node *n, ir_node **confirm) { * - A SymConst(entity) is NEVER a NULL pointer * - Confirms are evaluated */ -int value_not_null(ir_node *n, ir_node **confirm) { - ir_op *op; +int value_not_null(const ir_node *n, ir_node_cnst_ptr *confirm) { + tarval *tv; *confirm = NULL; - n = skip_Cast(n); + n = skip_Cast_const(n); + + tv = value_of(n); + if (tarval_is_constant(tv) && ! tarval_is_null(tv)) + return 1; - op = get_irn_op(n); assert(mode_is_reference(get_irn_mode(n))); if (get_opt_sel_based_null_check_elim()) { /* skip all Sel nodes and Cast's */ - while (op == op_Sel) { + while (is_Sel(n)) { n = skip_Cast(get_Sel_ptr(n)); - op = get_irn_op(n); } } if (is_Global(n)) { @@ -196,15 +198,14 @@ int value_not_null(ir_node *n, ir_node **confirm) { } else if (n == get_irg_frame(current_ir_graph)) { /* local references are never NULL */ return 1; - } else if (op == op_Const) { - /* explicit non-NULL addresses */ - return !is_Const_null(n); } else { /* check for more Confirms */ for (; is_Confirm(n); n = skip_Cast(get_Confirm_value(n))) { - if (get_Confirm_cmp(n) != pn_Cmp_Lg) { + if (get_Confirm_cmp(n) == pn_Cmp_Lg) { ir_node *bound = get_Confirm_bound(n); - if (is_Const(bound) && is_Const_null(bound)) { + tarval *tv = value_of(bound); + + if (tarval_is_null(tv)) { *confirm = n; return 1; } @@ -768,8 +769,8 @@ check_null_case: if ((pnc == pn_Cmp_Eq || pnc == pn_Cmp_Lg) && is_Const(right) && is_Const_null(right)) { /* for == 0 or != 0 we have some special tools */ - ir_mode *mode = get_irn_mode(left); - ir_node *dummy; + ir_mode *mode = get_irn_mode(left); + const ir_node *dummy; if (mode_is_reference(mode)) { if (value_not_null(left, &dummy)) { tv = pnc == pn_Cmp_Eq ? tarval_b_false : tarval_b_true;