diff options
author | Torbjorn Granlund <tege@gnu.org> | 1994-01-03 21:59:04 +0000 |
---|---|---|
committer | Torbjorn Granlund <tege@gnu.org> | 1994-01-03 21:59:04 +0000 |
commit | 8b39ed65f13d64dbf5fe0083837eb1cbf039a5f4 (patch) | |
tree | d0e525f2fb27f91e0d80d35d569661ba38170f28 | |
parent | 61f275ffe786a4003baf23a4dae8b044a59ea8fd (diff) | |
download | gcc-8b39ed65f13d64dbf5fe0083837eb1cbf039a5f4.zip gcc-8b39ed65f13d64dbf5fe0083837eb1cbf039a5f4.tar.gz gcc-8b39ed65f13d64dbf5fe0083837eb1cbf039a5f4.tar.bz2 |
(build_binary_op, case *_DIV_EXPR): Use same shorten
condition as for TRUNC_MOD_EXPR.
From-SVN: r6353
-rw-r--r-- | gcc/c-typeck.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index bc95508..b952828 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -1940,9 +1940,17 @@ build_binary_op (code, orig_op0, orig_op1, convert_p) if (!(code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)) resultcode = RDIV_EXPR; else - /* When dividing two signed integers, you have to promote to int. - E.g. (short) -32768 / (short) -1 doesn't fit in a short. */ - shorten = TREE_UNSIGNED (orig_op0); + { + /* Although it would be tempting to shorten always here, that + loses on some targets, since the modulo instruction is + undefined if the quotient can't be represented in the + computation mode. We shorten only if unsigned or if + dividing by something we know != -1. */ + shorten = (TREE_UNSIGNED (orig_op0) + || (TREE_CODE (op1) == INTEGER_CST + && (TREE_INT_CST_LOW (op1) != -1 + || TREE_INT_CST_HIGH (op1) != -1))); + } common = 1; } break; |