switch (e1->kind)
{
case CONSTANT:
- return expressions_equal_p (PRE_EXPR_CONSTANT (e1),
- PRE_EXPR_CONSTANT (e2));
+ {
+ tree const0 = PRE_EXPR_CONSTANT (e1);
+ tree const1 = PRE_EXPR_CONSTANT (e2);
+ return TREE_TYPE (const1) == TREE_TYPE (const0)
+ && expressions_equal_p (const0, const1);
+ }
+ break;
case NAME:
return PRE_EXPR_NAME (e1) == PRE_EXPR_NAME (e2);
case NARY:
result_id = lookup_expression_id (result);
if (result_id != 0)
{
- pool_free (pre_expr_pool, result);
- result = expression_for_id (result_id);
+ pre_expr newresult = expression_for_id (result_id);
+ pool_free (pre_expr_pool, result);
+ result = newresult;
return result;
}
get_or_alloc_expression_id (result);
result_id = lookup_expression_id (newexpr);
if (result_id != 0)
{
- pool_free (pre_expr_pool, newexpr);
- newexpr = expression_for_id (result_id);
+ pre_expr newresult = expression_for_id (result_id);
+ pool_free (pre_expr_pool, newexpr);
+ newexpr = newresult;
return newexpr;
}
value_id = get_or_alloc_constant_value_id (constant);
a constant. */
static tree
-get_constant_for_value_id (unsigned int v)
+get_constant_for_value_id (unsigned int v, tree type)
{
if (value_id_constant_p (v))
{
FOR_EACH_EXPR_ID_IN_SET (exprset, i, bi)
{
pre_expr expr = expression_for_id (i);
- if (expr->kind == CONSTANT)
+ if (expr->kind == CONSTANT
+ && TREE_TYPE (PRE_EXPR_CONSTANT (expr)) == type)
return PRE_EXPR_CONSTANT (expr);
}
}
pre_expr rep1 = get_or_alloc_expr_for (naryop1);
unsigned int vrep0 = get_expr_value_id (rep0);
unsigned int vrep1 = get_expr_value_id (rep1);
- tree const0 = get_constant_for_value_id (vrep0);
- tree const1 = get_constant_for_value_id (vrep1);
+ tree const0 = get_constant_for_value_id (vrep0,
+ TREE_TYPE (nary->op[0]));
+ tree const1 = get_constant_for_value_id (vrep1,
+ TREE_TYPE (nary->op[1]));
tree result = NULL;
if (const0 && const1)
{
tree naryop0 = nary->op[0];
pre_expr rep0 = get_or_alloc_expr_for (naryop0);
unsigned int vrep0 = get_expr_value_id (rep0);
- tree const0 = get_constant_for_value_id (vrep0);
+ tree const0 = get_constant_for_value_id (vrep0,
+ TREE_TYPE (nary->op[0]));
tree result = NULL;
if (const0)
{
find_or_generate_expression (basic_block block, pre_expr expr, tree stmts,
tree domstmt)
{
- pre_expr leader = bitmap_find_leader (AVAIL_OUT (block),
- get_expr_value_id (expr), domstmt);
+ pre_expr leader;
tree genop = NULL;
+
+ if (expr->kind == CONSTANT)
+ return PRE_EXPR_CONSTANT (expr);
+
+ leader = bitmap_find_leader (AVAIL_OUT (block),
+ get_expr_value_id (expr), domstmt);
if (leader)
{
if (leader->kind == NAME)
stmts, domstmt);
if (!genop1 || !genop2)
return NULL_TREE;
+
genop1 = fold_convert (TREE_TYPE (nary->op[0]),
genop1);
- /* Ensure op2 is a sizetype for POINTER_PLUS_EXPR. It
- may be a constant with the wrong type. */
- if (nary->opcode == POINTER_PLUS_EXPR)
- genop2 = fold_convert (sizetype, genop2);
- else
- genop2 = fold_convert (TREE_TYPE (nary->op[1]), genop2);
+ genop2 = fold_convert (TREE_TYPE (nary->op[1]), genop2);
folded = fold_build2 (nary->opcode, nary->type,
genop1, genop2);
}
eprime = fully_constant_expression (eprime);
- vprime = get_expr_value_id (eprime);
- edoubleprime = bitmap_find_leader (AVAIL_OUT (bprime),
- vprime, NULL_TREE);
+ if (eprime->kind == CONSTANT)
+ {
+ edoubleprime = eprime;
+ }
+ else
+ {
+ vprime = get_expr_value_id (eprime);
+ edoubleprime = bitmap_find_leader (AVAIL_OUT (bprime),
+ vprime, NULL_TREE);
+ }
if (edoubleprime == NULL)
{
avail[bprime->index] = eprime;
}
eprime = fully_constant_expression (eprime);
- vprime = get_expr_value_id (eprime);
- edoubleprime = bitmap_find_leader (AVAIL_OUT (bprime),
- vprime, NULL_TREE);
+ if (eprime->kind == CONSTANT)
+ {
+ edoubleprime = eprime;
+ }
+ else
+ {
+ vprime = get_expr_value_id (eprime);
+ edoubleprime = bitmap_find_leader (AVAIL_OUT (bprime),
+ vprime, NULL_TREE);
+ }
+
if (edoubleprime == NULL)
{
by_all = false;