[4/4] x86: minor improvements to optimize_imm() (part II)

Message ID 7d8305ec-478b-3577-2cd4-facd9d1e1c82@suse.com
State New
Headers show
Series
  • x86: suppress a bogus warning plus some cleanup
Related show

Commit Message

Jan Beulich via Binutils June 7, 2021, 12:41 p.m.
Don't kind-of-open-code fits_in_unsigned_{word,long}().

gas/
2021-06-XX  Jan Beulich  <jbeulich@suse.com>

	* config/tc-i386.c (optimize_imm): Use fits_in_unsigned_word
	and fits_in_unsigned_long.
---
I suppose the BFD64 conditional could now be dropped again, but that's
perhaps something for a separate change then.

Patch

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -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))