summaryrefslogtreecommitdiff
path: root/gcc/gimple-fold.c
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2011-05-21 15:01:15 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2011-05-21 15:01:15 +0000
commit16505e54d862368f604d014034e556fb359b7754 (patch)
tree31e4e9742f330f0eb81d52e9f17c01cda5a74306 /gcc/gimple-fold.c
parent41ac64ae1f281e5a657d87aeaadf1547b9b692b7 (diff)
downloadgcc-16505e54d862368f604d014034e556fb359b7754.tar.gz
2011-05-21 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 173996 using svnmerge git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@173997 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r--gcc/gimple-fold.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index e5303e31f7e..c98fd6a0d40 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -1,5 +1,5 @@
/* Statement simplification on GIMPLE.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010, 2011 Free Software Foundation, Inc.
Split out from tree-ssa-ccp.c.
This file is part of GCC.
@@ -2276,10 +2276,22 @@ and_comparisons_1 (enum tree_code code1, tree op1a, tree op1b,
code2, op2a, op2b))
return NULL_TREE;
}
- else if (TREE_CODE (arg) == SSA_NAME)
+ else if (TREE_CODE (arg) == SSA_NAME
+ && !SSA_NAME_IS_DEFAULT_DEF (arg))
{
- tree temp = and_var_with_comparison (arg, invert,
- code2, op2a, op2b);
+ tree temp;
+ gimple def_stmt = SSA_NAME_DEF_STMT (arg);
+ /* In simple cases we can look through PHI nodes,
+ but we have to be careful with loops.
+ See PR49073. */
+ if (! dom_info_available_p (CDI_DOMINATORS)
+ || gimple_bb (def_stmt) == gimple_bb (stmt)
+ || dominated_by_p (CDI_DOMINATORS,
+ gimple_bb (def_stmt),
+ gimple_bb (stmt)))
+ return NULL_TREE;
+ temp = and_var_with_comparison (arg, invert, code2,
+ op2a, op2b);
if (!temp)
return NULL_TREE;
else if (!result)
@@ -2726,10 +2738,22 @@ or_comparisons_1 (enum tree_code code1, tree op1a, tree op1b,
code2, op2a, op2b))
return NULL_TREE;
}
- else if (TREE_CODE (arg) == SSA_NAME)
+ else if (TREE_CODE (arg) == SSA_NAME
+ && !SSA_NAME_IS_DEFAULT_DEF (arg))
{
- tree temp = or_var_with_comparison (arg, invert,
- code2, op2a, op2b);
+ tree temp;
+ gimple def_stmt = SSA_NAME_DEF_STMT (arg);
+ /* In simple cases we can look through PHI nodes,
+ but we have to be careful with loops.
+ See PR49073. */
+ if (! dom_info_available_p (CDI_DOMINATORS)
+ || gimple_bb (def_stmt) == gimple_bb (stmt)
+ || dominated_by_p (CDI_DOMINATORS,
+ gimple_bb (def_stmt),
+ gimple_bb (stmt)))
+ return NULL_TREE;
+ temp = or_var_with_comparison (arg, invert, code2,
+ op2a, op2b);
if (!temp)
return NULL_TREE;
else if (!result)