x86: minor improvements to optimize_imm() (part II)
authorJan Beulich <jbeulich@suse.com>
Tue, 8 Jun 2021 12:57:18 +0000 (14:57 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 8 Jun 2021 12:57:18 +0000 (14:57 +0200)
Don't kind-of-open-code fits_in_unsigned_{word,long}().

gas/ChangeLog
gas/config/tc-i386.c

index 5f19f8590cfc5c5fd663300d69be4bfb3382238e..935efaa24d2afbd66fb47df99a0587a3bf53588f 100644 (file)
@@ -1,3 +1,8 @@
+2021-06-08  Jan Beulich  <jbeulich@suse.com>
+
+       * config/tc-i386.c (optimize_imm): Use fits_in_unsigned_word
+       and fits_in_unsigned_long.
+
 2021-06-08  Jan Beulich  <jbeulich@suse.com>
 
        * config/tc-i386.c (optimize_disp): Use fits_in_unsigned_word
index 17398ee987d18276d16d0ca9cd3ad165c363794b..80b70986fa5a49e130b339a675944ea2a721fda8 100644 (file)
@@ -5793,7 +5793,7 @@ optimize_imm (void)
               This allows a 16-bit operand such as $0xffe0 to
               be recognised as within Imm8S range.  */
            if ((i.types[op].bitfield.imm16)
-               && (i.op[op].imms->X_add_number & ~(offsetT) 0xffff) == 0)
+               && fits_in_unsigned_word (i.op[op].imms->X_add_number))
              {
                i.op[op].imms->X_add_number = ((i.op[op].imms->X_add_number
                                                ^ 0x8000) - 0x8000);
@@ -5801,8 +5801,7 @@ optimize_imm (void)
 #ifdef BFD64
            /* Store 32-bit immediate in 64-bit for 64-bit BFD.  */
            if ((i.types[op].bitfield.imm32)
-               && ((i.op[op].imms->X_add_number & ~(((offsetT) 2 << 31) - 1))
-                   == 0))
+               && fits_in_unsigned_long (i.op[op].imms->X_add_number))
              {
                i.op[op].imms->X_add_number = ((i.op[op].imms->X_add_number
                                                ^ ((offsetT) 1 << 31))