aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2021-06-08 14:56:39 +0200
committerJan Beulich <jbeulich@suse.com>2021-06-08 14:56:39 +0200
commitcd613c1fccd8c3b7872bea76da6a048c41884d41 (patch)
treea6ab4fab71904097e202a1519139854fe81dbdf5 /gas
parent77c59789070949a1cfbd19578c6935ccd57869c2 (diff)
downloadgdb-cd613c1fccd8c3b7872bea76da6a048c41884d41.zip
gdb-cd613c1fccd8c3b7872bea76da6a048c41884d41.tar.gz
gdb-cd613c1fccd8c3b7872bea76da6a048c41884d41.tar.bz2
x86: minor improvements to optimize_disp() (part II)
- Don't kind-of-open-code fits_in_unsigned_{word,long}(). - Fold two if()s both using fits_in_unsigned_long().
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog5
-rw-r--r--gas/config/tc-i386.c12
2 files changed, 10 insertions, 7 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index e2084f8..5f19f85 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,10 @@
2021-06-08 Jan Beulich <jbeulich@suse.com>
+ * config/tc-i386.c (optimize_disp): Use fits_in_unsigned_word
+ and fits_in_unsigned_long. Combine if()s.
+
+2021-06-08 Jan Beulich <jbeulich@suse.com>
+
* config/tc-i386.c (optimize_disp): Write back updated value.
* testsuite/gas/i386/lea16.s, testsuite/gas/i386/lea64.s: New
cases.
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 249f1c3..17398ee 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -5893,7 +5893,7 @@ optimize_disp (void)
}
if (i.types[op].bitfield.disp16
- && (op_disp & ~(offsetT) 0xffff) == 0)
+ && fits_in_unsigned_word (op_disp))
{
/* If this operand is at most 16 bits, convert
to a signed 16 bit number and don't use 64bit
@@ -5905,19 +5905,17 @@ optimize_disp (void)
#ifdef BFD64
if (flag_code == CODE_64BIT)
{
- if (want_disp32 (current_templates->start)
- && fits_in_unsigned_long (op_disp))
- i.types[op].bitfield.disp32 = 1;
-
/* Optimize 64-bit displacement to 32-bit for 64-bit BFD. */
- if (i.types[op].bitfield.disp32
- && (op_disp & ~(((offsetT) 2 << 31) - 1)) == 0)
+ if ((i.types[op].bitfield.disp32
+ || want_disp32 (current_templates->start))
+ && fits_in_unsigned_long (op_disp))
{
/* If this operand is at most 32 bits, convert
to a signed 32 bit number and don't use 64bit
displacement. */
op_disp = (op_disp ^ ((offsetT) 1 << 31)) - ((addressT) 1 << 31);
i.types[op].bitfield.disp64 = 0;
+ i.types[op].bitfield.disp32 = 1;
}
if (fits_in_signed_long (op_disp))