diff options
author | Richard Guenther <rguenther@suse.de> | 2011-07-19 10:57:15 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2011-07-19 10:57:15 +0000 |
commit | 530206482667dd180acc4ca1e339389308f0736b (patch) | |
tree | fd9ee6dcb0f9d2b3d7aaed6a958cf751208c3602 /gcc/gimplify.c | |
parent | b8b2b0094a9047a1ad476d96f0d20d4b56fca625 (diff) | |
download | gcc-530206482667dd180acc4ca1e339389308f0736b.zip gcc-530206482667dd180acc4ca1e339389308f0736b.tar.gz gcc-530206482667dd180acc4ca1e339389308f0736b.tar.bz2 |
gimplify.c (gimplify_expr): Gimplify TRUTH_NOT_EXPR as BIT_XOR_EXPR, same as the RTL expander does.
2011-07-19 Richard Guenther <rguenther@suse.de>
* gimplify.c (gimplify_expr): Gimplify TRUTH_NOT_EXPR as
BIT_XOR_EXPR, same as the RTL expander does.
* tree-cfg.c (verify_expr): Disallow TRUTH_NOT_EXPR in the gimple IL.
(verify_gimple_assign_unary): Likewise.
* tree-ssa-propagate.c (valid_gimple_rhs_p): Disallow TRUTH_*_EXPR.
* tree-ssa-forwprop.c (forward_propagate_comparison): Handle
BIT_NOT_EXPR and BIT_XOR_EXPR instead of TRUTH_NOT_EXPR.
* gcc.dg/tree-ssa/bool-10.c: Adjust expected pattern.
* gcc.dg/tree-ssa/bool-11.c: Likewise.
* gcc.dg/torture/20110719-1.c: New testcase.
From-SVN: r176442
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r-- | gcc/gimplify.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c index d1ce6d3..03e2ca6 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -6787,17 +6787,24 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, case TRUTH_NOT_EXPR: { - tree orig_type = TREE_TYPE (*expr_p); + tree type = TREE_TYPE (*expr_p); + /* The parsers are careful to generate TRUTH_NOT_EXPR + only with operands that are always zero or one. + We do not fold here but handle the only interesting case + manually, as fold may re-introduce the TRUTH_NOT_EXPR. */ *expr_p = gimple_boolify (*expr_p); - if (!useless_type_conversion_p (orig_type, TREE_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); + if (TYPE_PRECISION (TREE_TYPE (*expr_p)) == 1) + *expr_p = build1_loc (input_location, BIT_NOT_EXPR, + TREE_TYPE (*expr_p), + TREE_OPERAND (*expr_p, 0)); + else + *expr_p = build2_loc (input_location, BIT_XOR_EXPR, + TREE_TYPE (*expr_p), + TREE_OPERAND (*expr_p, 0), + build_int_cst (TREE_TYPE (*expr_p), 1)); + if (!useless_type_conversion_p (type, TREE_TYPE (*expr_p))) + *expr_p = fold_convert_loc (input_location, type, *expr_p); + ret = GS_OK; break; } |