diff options
| author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-07-17 19:01:54 +0000 |
|---|---|---|
| committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-07-17 19:01:54 +0000 |
| commit | 6217609825a7820b183a8687597809f2c0009e6c (patch) | |
| tree | c9572ed6e5246afd03ce187bb2507cce9039341a /gcc/c-typeck.c | |
| parent | 1e6011849811e5aa133e9f7039cbdb5c3c20794d (diff) | |
| download | ppe42-gcc-6217609825a7820b183a8687597809f2c0009e6c.tar.gz ppe42-gcc-6217609825a7820b183a8687597809f2c0009e6c.zip | |
* c-typeck.c (build_binary_op): Do not shorten unsigned
right shift after sign extension.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@44080 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-typeck.c')
| -rw-r--r-- | gcc/c-typeck.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 9e50c37da69..7bde430e8cb 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -2469,22 +2469,12 @@ build_binary_op (code, orig_op0, orig_op1, convert_p) /* We can shorten only if the shift count is less than the number of bits in the smaller type size. */ && compare_tree_int (op1, TYPE_PRECISION (TREE_TYPE (arg0))) < 0 - /* If arg is sign-extended and then unsigned-shifted, - we can simulate this with a signed shift in arg's type - only if the extended result is at least twice as wide - as the arg. Otherwise, the shift could use up all the - ones made by sign-extension and bring in zeros. - We can't optimize that case at all, but in most machines - it never happens because available widths are 2**N. */ - && (!TREE_UNSIGNED (final_type) - || unsigned_arg - || (2 * TYPE_PRECISION (TREE_TYPE (arg0)) - <= TYPE_PRECISION (result_type)))) + /* We cannot drop an unsigned shift after sign-extension. */ + && (!TREE_UNSIGNED (final_type) || unsigned_arg)) { /* Do an unsigned shift if the operand was zero-extended. */ result_type - = signed_or_unsigned_type (unsigned_arg, - TREE_TYPE (arg0)); + = signed_or_unsigned_type (unsigned_arg, TREE_TYPE (arg0)); /* Convert value-to-be-shifted to that type. */ if (TREE_TYPE (op0) != result_type) op0 = convert (result_type, op0); |

