diff options
author | ktietz <ktietz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-07-21 12:11:28 +0000 |
---|---|---|
committer | ktietz <ktietz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-07-21 12:11:28 +0000 |
commit | 4b5f16587542d4fee5f60ec0b176c855ec68d6ec (patch) | |
tree | 3fcf31bae07e5780a558bd87b46dde066bfb218e /gcc/gimplify.c | |
parent | 85c94a648d9d1527f687cb74522cbdf28b7289d3 (diff) | |
download | gcc-4b5f16587542d4fee5f60ec0b176c855ec68d6ec.tar.gz |
ChangeLog gcc/
2011-07-21 Kai Tietz <ktietz@redhat.com>
* fold-const.c (fold_unary_loc): Preserve indirect
comparison cast to none-boolean type.
* tree-ssa.c (useless_type_conversion_p): Preserve cast
from/to boolean-type.
* gimplify.c (gimple_boolify): Handle boolification
of comparisons.
(gimplify_expr): Boolifiy non aggregate-typed
comparisons.
* tree-cfg.c (verify_gimple_comparison): Check result
type of comparison expression.
* tree-ssa-forwprop.c (forward_propagate_comparison):
Adjust test of condition result and disallow type-cast
sinking into comparison.
ChangeLog gcc/testsuite
2011-07-21 Kai Tietz <ktietz@redhat.com>
* gcc.dg/tree-ssa/pr30978.c: adjusted.
* gcc.dg/tree-ssa/ssa-fre-6.c: Likewise.
* gcc.dg/binop-xor1.c: Set to fail.
* gcc.dg/binop-xor3.c: Set to fail.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@176563 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r-- | gcc/gimplify.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 03e2ca622cb..af9cdd7c848 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2860,18 +2860,23 @@ gimple_boolify (tree expr) case TRUTH_NOT_EXPR: TREE_OPERAND (expr, 0) = gimple_boolify (TREE_OPERAND (expr, 0)); - /* FALLTHRU */ - case EQ_EXPR: case NE_EXPR: - case LE_EXPR: case GE_EXPR: case LT_EXPR: case GT_EXPR: /* These expressions always produce boolean results. */ - TREE_TYPE (expr) = boolean_type_node; + if (TREE_CODE (type) != BOOLEAN_TYPE) + TREE_TYPE (expr) = boolean_type_node; return expr; default: + if (COMPARISON_CLASS_P (expr)) + { + /* There expressions always prduce boolean results. */ + if (TREE_CODE (type) != BOOLEAN_TYPE) + TREE_TYPE (expr) = boolean_type_node; + return expr; + } /* Other expressions that get here must have boolean values, but might need to be converted to the appropriate mode. */ - if (type == boolean_type_node) + if (TREE_CODE (type) == BOOLEAN_TYPE) return expr; return fold_convert_loc (loc, boolean_type_node, expr); } @@ -7316,7 +7321,19 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, tree type = TREE_TYPE (TREE_OPERAND (*expr_p, 1)); if (!AGGREGATE_TYPE_P (type)) - goto expr_2; + { + tree org_type = TREE_TYPE (*expr_p); + *expr_p = gimple_boolify (*expr_p); + if (!useless_type_conversion_p (org_type, + TREE_TYPE (*expr_p))) + { + *expr_p = fold_convert_loc (input_location, + org_type, *expr_p); + ret = GS_OK; + } + else + goto expr_2; + } else if (TYPE_MODE (type) != BLKmode) ret = gimplify_scalar_mode_aggregate_compare (expr_p); else |