summaryrefslogtreecommitdiffstats
path: root/gcc/c-convert.c
diff options
context:
space:
mode:
authorkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>1992-07-17 10:37:06 +0000
committerkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>1992-07-17 10:37:06 +0000
commit6974e6ec592e004f967003388e23644db8e1a8f0 (patch)
tree669ca777615cff78533c929fd6af8c0e86b9ea81 /gcc/c-convert.c
parent0816f121aece1391e175cda84e2e6ca114f49593 (diff)
downloadppe42-gcc-6974e6ec592e004f967003388e23644db8e1a8f0.tar.gz
ppe42-gcc-6974e6ec592e004f967003388e23644db8e1a8f0.zip
(convert_to_integer): Don't add a NOP_EXPR in cases where we can
simply change the type of the entire tree. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@1616 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-convert.c')
-rw-r--r--gcc/c-convert.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/gcc/c-convert.c b/gcc/c-convert.c
index 564992af88f..d20db4c6289 100644
--- a/gcc/c-convert.c
+++ b/gcc/c-convert.c
@@ -137,7 +137,20 @@ convert_to_integer (type, expr)
register unsigned inprec = TYPE_PRECISION (intype);
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);
/* Here detect when we can distribute the truncation down past some arithmetic.
@@ -250,22 +263,6 @@ convert_to_integer (type, expr)
}
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 BIT_NOT_EXPR:
{
OpenPOWER on IntegriCloud