aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-dom.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2019-02-26 10:55:16 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2019-02-26 10:55:16 +0000
commitcf02f8a350498eed424aea4a2fff2cbfd646fd61 (patch)
tree82781cd998e8f5d9e4ddbbaf5ac556568adb6752 /gcc/tree-ssa-dom.c
parent0eaf141239b27fa96c41558eab8f5ffba70bed4e (diff)
downloadgcc-cf02f8a350498eed424aea4a2fff2cbfd646fd61.zip
gcc-cf02f8a350498eed424aea4a2fff2cbfd646fd61.tar.gz
gcc-cf02f8a350498eed424aea4a2fff2cbfd646fd61.tar.bz2
opt77.adb: New test.
* gnat.dg/opt77.adb: New test. * gnat.dg/opt77_pkg.ad[sb]: New helper. From-SVN: r269208
Diffstat (limited to 'gcc/tree-ssa-dom.c')
-rw-r--r--gcc/tree-ssa-dom.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 12647e7..4f4b7db 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -170,11 +170,10 @@ edge_info::derive_equivalences (tree name, tree value, int recursion_limit)
gimple *def_stmt = SSA_NAME_DEF_STMT (name);
if (is_gimple_assign (def_stmt))
{
- /* We know the result of DEF_STMT was zero. See if that allows
- us to deduce anything about the SSA_NAMEs used on the RHS. */
enum tree_code code = gimple_assign_rhs_code (def_stmt);
switch (code)
{
+ /* If the result of an OR is zero, then its operands are, too. */
case BIT_IOR_EXPR:
if (integer_zerop (value))
{
@@ -188,8 +187,7 @@ edge_info::derive_equivalences (tree name, tree value, int recursion_limit)
}
break;
- /* We know the result of DEF_STMT was one. See if that allows
- us to deduce anything about the SSA_NAMEs used on the RHS. */
+ /* If the result of an AND is nonzero, then its operands are, too. */
case BIT_AND_EXPR:
if (!integer_zerop (value))
{
@@ -296,7 +294,6 @@ edge_info::derive_equivalences (tree name, tree value, int recursion_limit)
break;
}
-
case EQ_EXPR:
case NE_EXPR:
{
@@ -336,7 +333,28 @@ edge_info::derive_equivalences (tree name, tree value, int recursion_limit)
case NEGATE_EXPR:
{
tree rhs = gimple_assign_rhs1 (def_stmt);
- tree res = fold_build1 (code, TREE_TYPE (rhs), value);
+ tree res;
+ /* If this is a NOT and the operand has a boolean range, then we
+ know its value must be zero or one. We are not supposed to
+ have a BIT_NOT_EXPR for boolean types with precision > 1 in
+ the general case, see e.g. the handling of TRUTH_NOT_EXPR in
+ the gimplifier, but it can be generated by match.pd out of
+ a BIT_XOR_EXPR wrapped in a BIT_AND_EXPR. Now the handling
+ of BIT_AND_EXPR above already forces a specific semantics for
+ boolean types with precision > 1 so we must do the same here,
+ otherwise we could change the semantics of TRUTH_NOT_EXPR for
+ boolean types with precision > 1. */
+ if (code == BIT_NOT_EXPR
+ && TREE_CODE (rhs) == SSA_NAME
+ && ssa_name_has_boolean_range (rhs))
+ {
+ if (integer_zerop (value))
+ res = build_one_cst (TREE_TYPE (rhs));
+ else
+ res = build_zero_cst (TREE_TYPE (rhs));
+ }
+ else
+ res = fold_build1 (code, TREE_TYPE (rhs), value);
derive_equivalences (rhs, res, recursion_limit - 1);
break;
}