diff options
author | Jim Wilson <wilson@gcc.gnu.org> | 1994-11-19 15:38:04 -0800 |
---|---|---|
committer | Jim Wilson <wilson@gcc.gnu.org> | 1994-11-19 15:38:04 -0800 |
commit | 6cb70f0c964435fe98fc97902490395911ca0eab (patch) | |
tree | ac009253615bd81195376eac76ee434d73dfd886 /gcc | |
parent | 03f3609810ce73d30c5ace972765dffc2f33124e (diff) | |
download | gcc-6cb70f0c964435fe98fc97902490395911ca0eab.zip gcc-6cb70f0c964435fe98fc97902490395911ca0eab.tar.gz gcc-6cb70f0c964435fe98fc97902490395911ca0eab.tar.bz2 |
(build_binary_op): Can shorten shift only if shift count
is less than size in bits of arg0.
From-SVN: r8528
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c-typeck.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index c40d08a..d31e186 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -2391,6 +2391,10 @@ build_binary_op (code, orig_op0, orig_op1, convert_p) unsigned_arg = TREE_UNSIGNED (TREE_TYPE (op0)); if (TYPE_PRECISION (TREE_TYPE (arg0)) < TYPE_PRECISION (result_type) + /* We can shorten only if the shift count is less than the + number of bits in the smaller type size. */ + && TREE_INT_CST_HIGH (op1) == 0 + && TYPE_PRECISION (TREE_TYPE (arg0)) > TREE_INT_CST_LOW (op1) /* 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 |