(build_binary_op): Can shorten shift only if shift count
authorJim Wilson <wilson@gcc.gnu.org>
Sat, 19 Nov 1994 23:38:04 +0000 (15:38 -0800)
committerJim Wilson <wilson@gcc.gnu.org>
Sat, 19 Nov 1994 23:38:04 +0000 (15:38 -0800)
is less than size in bits of arg0.

From-SVN: r8528

gcc/c-typeck.c

index c40d08ab0026714ab73420259e7b2e568c9c3dac..d31e18619013669b68a2f5bb335f6218eb6f2cab 100644 (file)
@@ -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