From 6cb70f0c964435fe98fc97902490395911ca0eab Mon Sep 17 00:00:00 2001 From: Jim Wilson Date: Sat, 19 Nov 1994 15:38:04 -0800 Subject: [PATCH] (build_binary_op): Can shorten shift only if shift count is less than size in bits of arg0. From-SVN: r8528 --- gcc/c-typeck.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index c40d08ab002..d31e1861901 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 -- 2.30.2