From 7e96fb68712d07f3a2c0d3e1b0b1a4faaa240f39 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Tue, 8 Jun 2021 14:57:18 +0200 Subject: [PATCH] x86: minor improvements to optimize_imm() (part II) Don't kind-of-open-code fits_in_unsigned_{word,long}(). --- gas/ChangeLog | 5 +++++ gas/config/tc-i386.c | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 5f19f8590cf..935efaa24d2 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +2021-06-08 Jan Beulich + + * config/tc-i386.c (optimize_imm): Use fits_in_unsigned_word + and fits_in_unsigned_long. + 2021-06-08 Jan Beulich * config/tc-i386.c (optimize_disp): Use fits_in_unsigned_word diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 17398ee987d..80b70986fa5 100644 --- 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)) -- 2.30.2