diff options
author | Richard Guenther <rguenther@suse.de> | 2011-07-14 11:23:02 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2011-07-14 11:23:02 +0000 |
commit | bd5d002e9947ea14e6144a1955ab0e227fc0bcf9 (patch) | |
tree | 64c9f71e7c605711b34bf91d3b44a7b49aca21f3 /gcc/gimplify.c | |
parent | 696b1960a5e72f91583370aeadb477800e8e7e3a (diff) | |
download | gcc-bd5d002e9947ea14e6144a1955ab0e227fc0bcf9.zip gcc-bd5d002e9947ea14e6144a1955ab0e227fc0bcf9.tar.gz gcc-bd5d002e9947ea14e6144a1955ab0e227fc0bcf9.tar.bz2 |
gimplify.c (gimplify_expr): Only do required conversions.
2011-07-14 Richard Guenther <rguenther@suse.de>
* gimplify.c (gimplify_expr): Only do required conversions.
From-SVN: r176267
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r-- | gcc/gimplify.c | 66 |
1 files changed, 30 insertions, 36 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 1d0b907..f313352 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. */ |