diff options
author | Roger Sayle <roger@eyesopen.com> | 2005-03-21 03:30:08 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2005-03-21 03:30:08 +0000 |
commit | 90ec750dbf67872ce3076fceaf3b8df570c75c45 (patch) | |
tree | 64a437ac2c7bf9dae4641ceb3ef591d6abc0a7e6 /gcc/fold-const.c | |
parent | 37dc0d8dc7248b0495b56a26ca436f3980271587 (diff) | |
download | gcc-90ec750dbf67872ce3076fceaf3b8df570c75c45.zip gcc-90ec750dbf67872ce3076fceaf3b8df570c75c45.tar.gz gcc-90ec750dbf67872ce3076fceaf3b8df570c75c45.tar.bz2 |
re PR middle-end/20539 (ICE in simplify_subreg, at simplify-rtx.c:3674)
PR middle-end/20539
* fold-const.c (fold_binary): Fix type mismatch between
TRUTH_{AND,OR,XOR}_EXPR nodes an their operands' types.
(fold_binary) <TRUTH_XOR_EXPR>: Avoid calling invert_truthvalue
for non-truth-valued expressions.
* c-common.c (c_common_truthvalue_conversion): Handle ERROR_MARK
and FUNCTION_DECL in the main switch.
<TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR, TRUTH_AND_EXPR, TRUTH_OR_EXPR,
TRUTH_XOR_EXPR>: When changing the result type of these tree nodes,
we also need to convert their operands to match.
<TRUTH_NOT_EXPR>: Likewise.
* gcc.c-torture/compile/pr13066-1.c: New test case.
* gcc.c-torture/compile/pr20539-1.c: Likewise.
* g++.dg/opt/pr13066-1.C: Likewise.
From-SVN: r96777
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index bc17c1d..848b167 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -7159,13 +7159,14 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) tem = fold (build2 (code == BIT_AND_EXPR ? TRUTH_AND_EXPR : code == BIT_IOR_EXPR ? TRUTH_OR_EXPR : TRUTH_XOR_EXPR, - type, fold_convert (boolean_type_node, arg0), + boolean_type_node, + fold_convert (boolean_type_node, arg0), fold_convert (boolean_type_node, arg1))); if (code == EQ_EXPR) tem = invert_truthvalue (tem); - return tem; + return fold_convert (type, tem); } if (TREE_CODE_CLASS (code) == tcc_comparison @@ -8717,7 +8718,14 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) return non_lvalue (fold_convert (type, arg0)); /* If the second arg is constant true, this is a logical inversion. */ if (integer_onep (arg1)) - return non_lvalue (fold_convert (type, invert_truthvalue (arg0))); + { + /* Only call invert_truthvalue if operand is a truth value. */ + if (TREE_CODE (TREE_TYPE (arg0)) != BOOLEAN_TYPE) + tem = fold (build1 (TRUTH_NOT_EXPR, TREE_TYPE (arg0), arg0)); + else + tem = invert_truthvalue (arg0); + return non_lvalue (fold_convert (type, tem)); + } /* Identical arguments cancel to zero. */ if (operand_equal_p (arg0, arg1, 0)) return omit_one_operand (type, integer_zero_node, arg0); |