re PR tree-optimization/43402 (dom1 miscompiles binary search)

PR tree-optimization/43402
	* tree-cfgcleanup.c (cleanup_control_expr_graph): Don't follow
	PHI chains of ssa names registered for update.

testsuite/
	* gcc.dg/pr43402.c: New testcase.

From-SVN: r157538
This commit is contained in:
Michael Matz 2010-03-18 12:20:50 +00:00 committed by Michael Matz
parent 8269067b2c
commit eb45755f64
4 changed files with 81 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2010-03-18 Michael Matz <matz@suse.de>
PR tree-optimization/43402
* tree-cfgcleanup.c (cleanup_control_expr_graph): Don't follow
PHI chains of ssa names registered for update.
2010-03-17 Peter Bergner <bergner@vnet.ibm.com>
PR target/42427

View File

@ -1,3 +1,8 @@
2010-03-18 Michael Matz <matz@suse.de>
PR tree-optimization/43402
* gcc.dg/pr43402.c: New testcase.
2010-03-17 Peter Bergner <bergner@vnet.ibm.com>
PR target/42427

View File

@ -0,0 +1,58 @@
/* { dg-do run } */
/* { dg-options "-O1 -fno-inline" } */
extern void abort (void);
static int something;
static int * converterData[2]={
&something, &something,
};
static struct {
const char *name;
int type;
} const cnvNameType[] = {
{ "bocu1", 1 },
{ "utf7", 1 },
{ "utf8", 1 }
};
const int * getAlgorithmicTypeFromName(const char *realName);
const int *
getAlgorithmicTypeFromName(const char *realName)
{
unsigned mid, start, limit;
unsigned lastMid;
int result;
start = 0;
limit = sizeof(cnvNameType)/sizeof(cnvNameType[0]);
mid = limit;
lastMid = 0xffffffff;
for (;;) {
mid = (start + limit) / 2;
if (lastMid == mid) { /* Have we moved? */
break; /* We haven't moved, and it wasn't found. */
}
lastMid = mid;
result = __builtin_strcmp(realName, cnvNameType[mid].name);
if (result < 0) {
limit = mid;
} else if (result > 0) {
start = mid;
} else {
return converterData[cnvNameType[mid].type];
}
}
return 0;
}
int main (void)
{
if (!getAlgorithmicTypeFromName ("utf8"))
abort ();
return 0;
}

View File

@ -103,20 +103,28 @@ cleanup_control_expr_graph (basic_block bb, gimple_stmt_iterator gsi)
/* For conditions try harder and lookup single-argument
PHI nodes. Only do so from the same basic-block though
as other basic-blocks may be dead already. */
if (TREE_CODE (lhs) == SSA_NAME)
if (TREE_CODE (lhs) == SSA_NAME
&& !name_registered_for_update_p (lhs))
{
gimple def_stmt = SSA_NAME_DEF_STMT (lhs);
if (gimple_code (def_stmt) == GIMPLE_PHI
&& gimple_phi_num_args (def_stmt) == 1
&& gimple_bb (def_stmt) == gimple_bb (stmt))
&& gimple_bb (def_stmt) == gimple_bb (stmt)
&& (TREE_CODE (PHI_ARG_DEF (def_stmt, 0)) != SSA_NAME
|| !name_registered_for_update_p (PHI_ARG_DEF (def_stmt,
0))))
lhs = PHI_ARG_DEF (def_stmt, 0);
}
if (TREE_CODE (rhs) == SSA_NAME)
if (TREE_CODE (rhs) == SSA_NAME
&& !name_registered_for_update_p (rhs))
{
gimple def_stmt = SSA_NAME_DEF_STMT (rhs);
if (gimple_code (def_stmt) == GIMPLE_PHI
&& gimple_phi_num_args (def_stmt) == 1
&& gimple_bb (def_stmt) == gimple_bb (stmt))
&& gimple_bb (def_stmt) == gimple_bb (stmt)
&& (TREE_CODE (PHI_ARG_DEF (def_stmt, 0)) != SSA_NAME
|| !name_registered_for_update_p (PHI_ARG_DEF (def_stmt,
0))))
rhs = PHI_ARG_DEF (def_stmt, 0);
}
val = fold_binary_loc (loc, gimple_cond_code (stmt),