]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - opcodes/tilegx-opc.c
Remove more shifts for sign/zero extension
[thirdparty/binutils-gdb.git] / opcodes / tilegx-opc.c
index 49819e8453f0924771b2064aec5b026f4075a2ae..cc9ce861b9a506cececa8c4f72fad563b443e47b 100644 (file)
@@ -8102,8 +8102,8 @@ parse_insn_tilegx (tilegx_bundle_bits bits,
          if (op->is_signed)
            {
              /* Sign-extend the operand.  */
-             int shift = (int)((sizeof(int) * 8) - op->num_bits);
-             raw_opval = (raw_opval << shift) >> shift;
+             unsigned int sign = 1u << (op->num_bits - 1);
+             raw_opval = ((raw_opval & (sign + sign - 1)) ^ sign) - sign;
            }
 
          /* Adjust PC-relative scaled branch offsets.  */