Commit f3964bb8 by Richard Kenner

(convert_to_integer): Don't add a NOP_EXPR in cases where we can

simply change the type of the entire tree.

From-SVN: r1616
parent 0c2e838b
...@@ -137,7 +137,20 @@ convert_to_integer (type, expr) ...@@ -137,7 +137,20 @@ convert_to_integer (type, expr)
register unsigned inprec = TYPE_PRECISION (intype); register unsigned inprec = TYPE_PRECISION (intype);
register enum tree_code ex_form = TREE_CODE (expr); register enum tree_code ex_form = TREE_CODE (expr);
if (outprec >= inprec) /* If we are widening the type, put in an explicit conversion.
Similarly if we are not changing the width. However, if this is
a logical operation that just returns 0 or 1, we can change the
type of the expression (see below). */
if (TREE_CODE_CLASS (ex_form) == '<'
|| ex_form == TRUTH_AND_EXPR || ex_form == TRUTH_ANDIF_EXPR
|| ex_form == TRUTH_OR_EXPR || ex_form == TRUTH_ORIF_EXPR
|| ex_form == TRUTH_NOT_EXPR)
{
TREE_TYPE (expr) = type;
return expr;
}
else if (outprec >= inprec)
return build1 (NOP_EXPR, type, expr); return build1 (NOP_EXPR, type, expr);
/* Here detect when we can distribute the truncation down past some arithmetic. /* Here detect when we can distribute the truncation down past some arithmetic.
...@@ -250,22 +263,6 @@ convert_to_integer (type, expr) ...@@ -250,22 +263,6 @@ convert_to_integer (type, expr)
} }
break; break;
case EQ_EXPR:
case NE_EXPR:
case GT_EXPR:
case GE_EXPR:
case LT_EXPR:
case LE_EXPR:
case TRUTH_AND_EXPR:
case TRUTH_ANDIF_EXPR:
case TRUTH_OR_EXPR:
case TRUTH_ORIF_EXPR:
case TRUTH_NOT_EXPR:
/* If we want result of comparison converted to a byte,
we can just regard it as a byte, since it is 0 or 1. */
TREE_TYPE (expr) = type;
return expr;
case NEGATE_EXPR: case NEGATE_EXPR:
case BIT_NOT_EXPR: case BIT_NOT_EXPR:
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment