X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ast2firm.c;h=581b983a5c615527b1b0bae0de218ea9202f188a;hb=643026ae19cfdb8e3c891407f155668768028325;hp=1016fe80a3e55bee722db95af60e44007a0afba0;hpb=928c95eb0d61447ba767cae34d4f9a8747d674b8;p=cparser diff --git a/ast2firm.c b/ast2firm.c index 1016fe8..581b983 100644 --- a/ast2firm.c +++ b/ast2firm.c @@ -2394,12 +2394,24 @@ static ir_node *create_lazy_op(const binary_expression_t *expression) long val = fold_constant(expression->left); expression_kind_t ekind = expression->base.kind; assert(ekind == EXPR_BINARY_LOGICAL_AND || ekind == EXPR_BINARY_LOGICAL_OR); - if ((ekind == EXPR_BINARY_LOGICAL_AND && val != 0) || - (ekind == EXPR_BINARY_LOGICAL_OR && val == 0)) { - return produce_condition_result(expression->right, mode, dbgi); + if (ekind == EXPR_BINARY_LOGICAL_AND) { + if (val == 0) { + return new_Const(get_mode_null(mode)); + } } else { - return new_Const(get_mode_one(mode)); + if (val != 0) { + return new_Const(get_mode_one(mode)); + } + } + + if (is_constant_expression(expression->right)) { + long const valr = fold_constant(expression->left); + return valr != 0 ? + new_Const(get_mode_one(mode)) : + new_Const(get_mode_null(mode)); } + + return produce_condition_result(expression->right, mode, dbgi); } return produce_condition_result((const expression_t*) expression, mode, @@ -3305,9 +3317,7 @@ static ir_node *create_condition_evaluation(const expression_t *expression, } add_immBlock_pred(true_block, true_proj); - if (false_block != NULL) { - add_immBlock_pred(false_block, false_proj); - } + add_immBlock_pred(false_block, false_proj); set_cur_block(NULL); return cond_expr; @@ -4487,9 +4497,7 @@ static void do_while_statement_to_firm(do_while_statement_t *statement) create_condition_evaluation(statement->condition, body_block, false_block); mature_immBlock(body_block); mature_immBlock(header_block); - if (false_block != NULL) { - mature_immBlock(false_block); - } + mature_immBlock(false_block); set_cur_block(false_block); } @@ -4542,7 +4550,7 @@ static void for_statement_to_firm(for_statement_t *statement) ir_node *const false_block = new_immBlock(); /* the loop body */ - ir_node * body_block; + ir_node *body_block; if (statement->body != NULL) { ir_node *const old_continue_label = continue_label; ir_node *const old_break_label = break_label;