From: Richard Guenther Date: Thu, 14 Jul 2011 11:23:02 +0000 (+0000) Subject: gimplify.c (gimplify_expr): Only do required conversions. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bd5d002e9947ea14e6144a1955ab0e227fc0bcf9;p=gcc.git gimplify.c (gimplify_expr): Only do required conversions. 2011-07-14 Richard Guenther * gimplify.c (gimplify_expr): Only do required conversions. From-SVN: r176267 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3cbc03c6330..9c5fed6ea2a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2011-07-14 Richard Guenther + + * gimplify.c (gimplify_expr): Only do required conversions. + 2011-07-14 Georg-Johann Lay PR target/43746 diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 1d0b9071e4a..f313352e8a2 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -6787,22 +6787,20 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, case TRUTH_NOT_EXPR: { - tree org_type = TREE_TYPE (*expr_p); - + tree orig_type = TREE_TYPE (*expr_p); *expr_p = gimple_boolify (*expr_p); - if (org_type != boolean_type_node) + if (!useless_type_conversion_p (orig_type, TREE_TYPE (*expr_p))) { - *expr_p = fold_convert (org_type, *expr_p); + *expr_p = fold_convert_loc (saved_location, orig_type, *expr_p); ret = GS_OK; break; } + ret = gimplify_expr (&TREE_OPERAND (*expr_p, 0), pre_p, post_p, + is_gimple_val, fb_rvalue); + recalculate_side_effects (*expr_p); + break; } - ret = gimplify_expr (&TREE_OPERAND (*expr_p, 0), pre_p, post_p, - is_gimple_val, fb_rvalue); - recalculate_side_effects (*expr_p); - break; - case ADDR_EXPR: ret = gimplify_addr_expr (expr_p, pre_p, post_p); break; @@ -7227,40 +7225,36 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, case TRUTH_OR_EXPR: case TRUTH_XOR_EXPR: { - tree org_type = TREE_TYPE (*expr_p); - + tree orig_type = TREE_TYPE (*expr_p); *expr_p = gimple_boolify (*expr_p); - - /* This shouldn't happen, but due fold-const (and here especially - fold_truth_not_expr) happily uses operand type and doesn't - automatically uses boolean_type as result, we need to keep - orignal type. */ - if (org_type != boolean_type_node) + if (!useless_type_conversion_p (orig_type, TREE_TYPE (*expr_p))) { - *expr_p = fold_convert (org_type, *expr_p); + *expr_p = fold_convert_loc (saved_location, orig_type, *expr_p); ret = GS_OK; break; } - } - /* With two-valued operand types binary truth expressions are - semantically equivalent to bitwise binary expressions. Canonicalize - them to the bitwise variant. */ switch (TREE_CODE (*expr_p)) - { - case TRUTH_AND_EXPR: - TREE_SET_CODE (*expr_p, BIT_AND_EXPR); - break; - case TRUTH_OR_EXPR: - TREE_SET_CODE (*expr_p, BIT_IOR_EXPR); - break; - case TRUTH_XOR_EXPR: - TREE_SET_CODE (*expr_p, BIT_XOR_EXPR); - break; - default: - break; + /* Boolified binary truth expressions are semantically equivalent + to bitwise binary expressions. Canonicalize them to the + bitwise variant. */ + switch (TREE_CODE (*expr_p)) + { + case TRUTH_AND_EXPR: + TREE_SET_CODE (*expr_p, BIT_AND_EXPR); + break; + case TRUTH_OR_EXPR: + TREE_SET_CODE (*expr_p, BIT_IOR_EXPR); + break; + case TRUTH_XOR_EXPR: + TREE_SET_CODE (*expr_p, BIT_XOR_EXPR); + break; + default: + break; + } + + /* Continue classified as tcc_binary. */ + goto expr_2; } - /* Classified as tcc_expression. */ - goto expr_2; case FMA_EXPR: /* Classified as tcc_expression. */