summaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2011-07-19 10:57:15 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2011-07-19 10:57:15 +0000
commit569b4ac886cb5d27f9a87019cda3f13b9446f23d (patch)
treefd9ee6dcb0f9d2b3d7aaed6a958cf751208c3602 /gcc/gimplify.c
parent40a1986400190dc55e2dc73b14b58e98b7631658 (diff)
downloadgcc-569b4ac886cb5d27f9a87019cda3f13b9446f23d.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@176442 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index d1ce6d3dce8..03e2ca622cb 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;
}