X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=ir%2Fopt%2Fopt_confirms.c;h=dc67eaf05379b23b250b946384983ba9cfb6be72;hb=1c67316903ab28e3f57ae68a5ad7488b359ab301;hp=2b33df94b5a45189f78c139aaeff9978ca73ae0f;hpb=10e58f9669ea6c77e82bd3bc12c4ac5bbaa6bb15;p=libfirm diff --git a/ir/opt/opt_confirms.c b/ir/opt/opt_confirms.c index 2b33df94b..dc67eaf05 100644 --- a/ir/opt/opt_confirms.c +++ b/ir/opt/opt_confirms.c @@ -21,7 +21,6 @@ * @file * @brief Optimizations regarding Confirm nodes. * @author Michael Beck - * @version $Id$ */ #include "config.h" @@ -67,25 +66,25 @@ static tarval *compare_iv_dbg(const interval_t *l_iv, const interval_t *r_iv, ir #define DBG_OUT_TR(l_relation, l_bound, r_relation, r_bound, relation, v) \ ir_printf("In %e:\na %= %n && b %= %n ==> a %= b == %s\n", \ get_irg_entity(current_ir_graph), \ - l_relation, l_bound, r_relation, r_bound, relation, v); + l_relation, l_bound, r_relation, r_bound, relation, v) /* right side */ #define DBG_OUT_R(r_relation, r_bound, left, relation, right, v) \ ir_printf("In %e:\na %= %n ==> %n %= %n == %s\n", \ get_irg_entity(current_ir_graph), \ - r_relation, r_bound, left, relation, right, v); + r_relation, r_bound, left, relation, right, v) /* left side */ #define DBG_OUT_L(l_relation, l_bound, left, relation, right, v) \ ir_printf("In %e:\na %= %n ==> %n %= %n == %s\n", \ get_irg_entity(current_ir_graph), \ - l_relation, l_bound, left, relation, right, v); + l_relation, l_bound, left, relation, right, v) #else -#define DBG_OUT_TR(l_relation, l_bound, r_relation, r_bound, relation, v) -#define DBG_OUT_R(r_relation, r_bound, left, relation, right, v) -#define DBG_OUT_L(l_relation, l_bound, left, relation, right, v) +#define DBG_OUT_TR(l_relation, l_bound, r_relation, r_bound, relation, v) (void)0 +#define DBG_OUT_R(r_relation, r_bound, left, relation, right, v) (void)0 +#define DBG_OUT_L(l_relation, l_bound, left, relation, right, v) (void)0 #endif /* DEBUG_CONFIRM */ @@ -95,9 +94,9 @@ static tarval *compare_iv_dbg(const interval_t *l_iv, const interval_t *r_iv, ir * This is a often needed case, so we handle here Confirm * nodes too. */ -FIRM_API int value_not_zero(const ir_node *n, ir_node_cnst_ptr *confirm) +int value_not_zero(const ir_node *n, const ir_node **confirm) { -#define RET_ON(x) if (x) { *confirm = n; return 1; }; break +#define RET_ON(x) if (x) { *confirm = n; return 1; } break ir_tarval *tv; ir_mode *mode = get_irn_mode(n); @@ -121,8 +120,10 @@ FIRM_API int value_not_zero(const ir_node *n, ir_node_cnst_ptr *confirm) * without the fear that is might be hidden by a further Confirm. */ tv = value_of(get_Confirm_bound(n)); - if (tv == tarval_bad) - return 0; + if (tv == tarval_bad) { + n = get_Confirm_value(n); + continue; + } relation = tarval_cmp(tv, get_mode_null(mode)); @@ -152,10 +153,13 @@ FIRM_API int value_not_zero(const ir_node *n, ir_node_cnst_ptr *confirm) } n = get_Confirm_value(n); } - tv = value_of(n); + /* global entities are never NULL */ + if (is_SymConst_addr_ent(n)) + return true; + tv = value_of(n); if (tv == tarval_bad) - return 0; + return false; relation = tarval_cmp(tv, get_mode_null(mode)); @@ -168,13 +172,11 @@ FIRM_API int value_not_zero(const ir_node *n, ir_node_cnst_ptr *confirm) /* * Check, if the value of a node cannot represent a NULL pointer. * - * - Casts are skipped - * - If sel_based_null_check_elim is enabled, all - * Sel nodes can be skipped. + * - Casts are skipped, Sels are skipped * - A SymConst(entity) is NEVER a NULL pointer * - Confirms are evaluated */ -FIRM_API int value_not_null(const ir_node *n, ir_node_cnst_ptr *confirm) +int value_not_null(const ir_node *n, const ir_node **confirm) { ir_tarval *tv; @@ -186,11 +188,9 @@ FIRM_API int value_not_null(const ir_node *n, ir_node_cnst_ptr *confirm) return 1; assert(mode_is_reference(get_irn_mode(n))); - if (get_opt_sel_based_null_check_elim()) { - /* skip all Sel nodes and Cast's */ - while (is_Sel(n)) { - n = skip_Cast(get_Sel_ptr(n)); - } + /* skip all Sel nodes and Cast's */ + while (is_Sel(n)) { + n = skip_Cast(get_Sel_ptr(n)); } while (1) { if (is_Cast(n)) { n = get_Cast_op(n); continue; } @@ -198,7 +198,7 @@ FIRM_API int value_not_null(const ir_node *n, ir_node_cnst_ptr *confirm) break; } - if (is_Global(n)) { + if (is_SymConst_addr_ent(n)) { /* global references are never NULL */ return 1; } else if (n == get_irg_frame(get_irn_irg(n))) { @@ -237,7 +237,7 @@ extern "C++" { * If the mode of the value did not honor signed zeros, else * check for >= 0 or < 0. */ -FIRM_API ir_value_classify_sign classify_value_sign(ir_node *n) +ir_value_classify_sign classify_value_sign(ir_node *n) { ir_tarval *tv, *c; ir_mode *mode; @@ -635,7 +635,7 @@ static int is_transitive(ir_relation relation) * @param right the right operand of the Cmp * @param relation the compare relation */ -FIRM_API ir_tarval *computed_value_Cmp_Confirm(const ir_node *cmp, ir_node *left, ir_node *right, ir_relation relation) +ir_tarval *computed_value_Cmp_Confirm(const ir_node *cmp, ir_node *left, ir_node *right, ir_relation relation) { ir_node *l_bound; ir_relation l_relation, res_relation, neg_relation;