diff options
author | Richard Kenner <kenner@gcc.gnu.org> | 1992-07-17 06:37:06 -0400 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 1992-07-17 06:37:06 -0400 |
commit | f3964bb8a3b4262473d1237707ca7388a17e3174 (patch) | |
tree | 669ca777615cff78533c929fd6af8c0e86b9ea81 /gcc/c-convert.c | |
parent | 0c2e838b251178be0a1eb709fc9e3d86d52f6577 (diff) | |
download | gcc-f3964bb8a3b4262473d1237707ca7388a17e3174.tar.gz |
(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
Diffstat (limited to 'gcc/c-convert.c')
-rw-r--r-- | gcc/c-convert.c | 31 |
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: { |