x86: Don't pad .tfloat output

Message ID 20210815203425.2511784-1-hjl.tools@gmail.com
State New
Headers show
Series
  • x86: Don't pad .tfloat output
Related show

Commit Message

Alan Modra via Binutils Aug. 15, 2021, 8:34 p.m.
.tfloat output should always be 10 bytes without padding, independent
of psABIs.  In glibc, x86 assembly codes expect 10-byte .tfloat output.
This also changes .ds.x output and .tfloat output with hex input to
match .tfloat output.

	PR gas/28230
	* config/tc-i386.c (x86_tfloat_pad): Removed.
	* config/tc-i386.h (X_PRECISION_PAD): Changed to 0.
	(x86_tfloat_pad): Removed.
	* testsuite/gas/i386/fp.s: If NO_TFLOAT_PADDING isn't defined,
	add explicit paddings after .tfloat, .ds.x, .dc.x and .dcb.x
	directives.
	* testsuite/gas/i386/i386.exp (ASFLAGS): Append
	"--defsym NO_TFLOAT_PADDING=1" when running the fp test.
---
 gas/config/tc-i386.c            |  13 ----
 gas/config/tc-i386.h            |   3 +-
 gas/testsuite/gas/i386/fp.s     | 119 ++++++++++++++++++++++++++++++++
 gas/testsuite/gas/i386/i386.exp |   3 +
 4 files changed, 123 insertions(+), 15 deletions(-)

-- 
2.31.1

Comments

Alan Modra via Binutils Aug. 16, 2021, 6:48 a.m. | #1
On 15.08.2021 22:34, H.J. Lu wrote:
> .tfloat output should always be 10 bytes without padding, independent

> of psABIs.


I disagree. It's been a long standing bug. I can see that affecting
existing code isn't nice, so I could see us emit e.g. a warning for
the time being. In the worst case we might add a command line option
to drive the behavior.

>  In glibc, x86 assembly codes expect 10-byte .tfloat output.

> This also changes .ds.x output and .tfloat output with hex input to

> match .tfloat output.


This leaves users without any ABI-conforming way to produce double
extended precision values, short of hand-coding the padding. Even if
you were really going to insist that retaining the broken behavior
of .tfloat is necessary, a directive providing correct behavior
should be available. This might then be .d{c,cb,s}.x, or something
new. But as said - to me this really would only be a last resort.
Whoever introduced .tfloat in its present way screwed up, and
whoever forgot to fix .tfloat for x86-64 didn't even pay attention
to the ABI difference.

> 	PR gas/28230

> 	* config/tc-i386.c (x86_tfloat_pad): Removed.

> 	* config/tc-i386.h (X_PRECISION_PAD): Changed to 0.

> 	(x86_tfloat_pad): Removed.

> 	* testsuite/gas/i386/fp.s: If NO_TFLOAT_PADDING isn't defined,

> 	add explicit paddings after .tfloat, .ds.x, .dc.x and .dcb.x

> 	directives.

> 	* testsuite/gas/i386/i386.exp (ASFLAGS): Append

> 	"--defsym NO_TFLOAT_PADDING=1" when running the fp test.


I'm afraid I don't understand the games you play here: If you
really thought .tfloat should not emit ABI-conforming data, then
why would you bother introducing NO_TFLOAT_PADDING to allow for
alternative behavior?

Jan
Andreas Schwab Aug. 16, 2021, 8:17 a.m. | #2
On Aug 16 2021, Jan Beulich via Binutils wrote:

> This leaves users without any ABI-conforming way to produce double

> extended precision values, short of hand-coding the padding.


If you want to use the C ABI, you should use a C compiler.  On the
assembler level, double extended precision have 10 bytes, which is what
the FPU reads and writes.  The manual clearly documents .tfloat as
producing 80-bit (ten byte) reals.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."
Alan Modra via Binutils Aug. 16, 2021, 8:59 a.m. | #3
On 16.08.2021 10:17, Andreas Schwab wrote:
> On Aug 16 2021, Jan Beulich via Binutils wrote:

> 

>> This leaves users without any ABI-conforming way to produce double

>> extended precision values, short of hand-coding the padding.

> 

> If you want to use the C ABI, you should use a C compiler.  On the

> assembler level, double extended precision have 10 bytes, which is what

> the FPU reads and writes.  The manual clearly documents .tfloat as

> producing 80-bit (ten byte) reals.


Well, the other consistent arrangement we could move to is for no
padding to ever get emitted - including .dc.x, .dcb.x, and .ds.x.
Personally I view this as less useful, but I could see us going
this route. The one thing that's a no-go imo is the inconsistent
state prior to the patch series (and it remaining that way on
other architectures also supporting double extended precision),
including this inconsistency even getting spelled out in the
documentation.

Jan
Alan Modra via Binutils Aug. 16, 2021, 1:40 p.m. | #4
On Sun, Aug 15, 2021 at 11:48 PM Jan Beulich <jbeulich@suse.com> wrote:
>

> On 15.08.2021 22:34, H.J. Lu wrote:

> > .tfloat output should always be 10 bytes without padding, independent

> > of psABIs.

>

> I disagree. It's been a long standing bug. I can see that affecting

> existing code isn't nice, so I could see us emit e.g. a warning for

> the time being. In the worst case we might add a command line option

> to drive the behavior.

>

> >  In glibc, x86 assembly codes expect 10-byte .tfloat output.

> > This also changes .ds.x output and .tfloat output with hex input to

> > match .tfloat output.

>

> This leaves users without any ABI-conforming way to produce double

> extended precision values, short of hand-coding the padding. Even if

> you were really going to insist that retaining the broken behavior

> of .tfloat is necessary, a directive providing correct behavior

> should be available. This might then be .d{c,cb,s}.x, or something

> new. But as said - to me this really would only be a last resort.

> Whoever introduced .tfloat in its present way screwed up, and

> whoever forgot to fix .tfloat for x86-64 didn't even pay attention

> to the ABI difference.

>

> >       PR gas/28230

> >       * config/tc-i386.c (x86_tfloat_pad): Removed.

> >       * config/tc-i386.h (X_PRECISION_PAD): Changed to 0.

> >       (x86_tfloat_pad): Removed.

> >       * testsuite/gas/i386/fp.s: If NO_TFLOAT_PADDING isn't defined,

> >       add explicit paddings after .tfloat, .ds.x, .dc.x and .dcb.x

> >       directives.

> >       * testsuite/gas/i386/i386.exp (ASFLAGS): Append

> >       "--defsym NO_TFLOAT_PADDING=1" when running the fp test.

>

> I'm afraid I don't understand the games you play here: If you

> really thought .tfloat should not emit ABI-conforming data, then

> why would you bother introducing NO_TFLOAT_PADDING to allow for

> alternative behavior?


Since I don't want to change fp-elf32.d nor fp-elf64.d, I added paddings
manually.  fp.d doesn't expect paddings.

-- 
H.J.
Alan Modra via Binutils Aug. 16, 2021, 1:42 p.m. | #5
On Mon, Aug 16, 2021 at 1:59 AM Jan Beulich <jbeulich@suse.com> wrote:
>

> On 16.08.2021 10:17, Andreas Schwab wrote:

> > On Aug 16 2021, Jan Beulich via Binutils wrote:

> >

> >> This leaves users without any ABI-conforming way to produce double

> >> extended precision values, short of hand-coding the padding.

> >

> > If you want to use the C ABI, you should use a C compiler.  On the

> > assembler level, double extended precision have 10 bytes, which is what

> > the FPU reads and writes.  The manual clearly documents .tfloat as

> > producing 80-bit (ten byte) reals.

>

> Well, the other consistent arrangement we could move to is for no

> padding to ever get emitted - including .dc.x, .dcb.x, and .ds.x.

> Personally I view this as less useful, but I could see us going

> this route. The one thing that's a no-go imo is the inconsistent

> state prior to the patch series (and it remaining that way on

> other architectures also supporting double extended precision),

> including this inconsistency even getting spelled out in the

> documentation.


My patch removes paddings for .tfloat with hex, .dc.x, .dcb.x,
and .ds.x.

-- 
H.J.
Alan Modra via Binutils Aug. 16, 2021, 3:28 p.m. | #6
On Mon, Aug 16, 2021 at 6:42 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>

> On Mon, Aug 16, 2021 at 1:59 AM Jan Beulich <jbeulich@suse.com> wrote:

> >

> > On 16.08.2021 10:17, Andreas Schwab wrote:

> > > On Aug 16 2021, Jan Beulich via Binutils wrote:

> > >

> > >> This leaves users without any ABI-conforming way to produce double

> > >> extended precision values, short of hand-coding the padding.

> > >

> > > If you want to use the C ABI, you should use a C compiler.  On the

> > > assembler level, double extended precision have 10 bytes, which is what

> > > the FPU reads and writes.  The manual clearly documents .tfloat as

> > > producing 80-bit (ten byte) reals.

> >

> > Well, the other consistent arrangement we could move to is for no

> > padding to ever get emitted - including .dc.x, .dcb.x, and .ds.x.

> > Personally I view this as less useful, but I could see us going

> > this route. The one thing that's a no-go imo is the inconsistent

> > state prior to the patch series (and it remaining that way on

> > other architectures also supporting double extended precision),

> > including this inconsistency even getting spelled out in the

> > documentation.

>

> My patch removes paddings for .tfloat with hex, .dc.x, .dcb.x,

> and .ds.x.

>


I will check in my patch today.

-- 
H.J.
Alan Modra via Binutils Aug. 17, 2021, 7:49 a.m. | #7
On 16.08.2021 15:40, H.J. Lu wrote:
> On Sun, Aug 15, 2021 at 11:48 PM Jan Beulich <jbeulich@suse.com> wrote:

>>

>> On 15.08.2021 22:34, H.J. Lu wrote:

>>> .tfloat output should always be 10 bytes without padding, independent

>>> of psABIs.

>>

>> I disagree. It's been a long standing bug. I can see that affecting

>> existing code isn't nice, so I could see us emit e.g. a warning for

>> the time being. In the worst case we might add a command line option

>> to drive the behavior.

>>

>>>  In glibc, x86 assembly codes expect 10-byte .tfloat output.

>>> This also changes .ds.x output and .tfloat output with hex input to

>>> match .tfloat output.

>>

>> This leaves users without any ABI-conforming way to produce double

>> extended precision values, short of hand-coding the padding. Even if

>> you were really going to insist that retaining the broken behavior

>> of .tfloat is necessary, a directive providing correct behavior

>> should be available. This might then be .d{c,cb,s}.x, or something

>> new. But as said - to me this really would only be a last resort.

>> Whoever introduced .tfloat in its present way screwed up, and

>> whoever forgot to fix .tfloat for x86-64 didn't even pay attention

>> to the ABI difference.

>>

>>>       PR gas/28230

>>>       * config/tc-i386.c (x86_tfloat_pad): Removed.

>>>       * config/tc-i386.h (X_PRECISION_PAD): Changed to 0.

>>>       (x86_tfloat_pad): Removed.

>>>       * testsuite/gas/i386/fp.s: If NO_TFLOAT_PADDING isn't defined,

>>>       add explicit paddings after .tfloat, .ds.x, .dc.x and .dcb.x

>>>       directives.

>>>       * testsuite/gas/i386/i386.exp (ASFLAGS): Append

>>>       "--defsym NO_TFLOAT_PADDING=1" when running the fp test.

>>

>> I'm afraid I don't understand the games you play here: If you

>> really thought .tfloat should not emit ABI-conforming data, then

>> why would you bother introducing NO_TFLOAT_PADDING to allow for

>> alternative behavior?

> 

> Since I don't want to change fp-elf32.d nor fp-elf64.d, I added paddings

> manually.  fp.d doesn't expect paddings.


But with .tfloat no longer honoring ABI there's no need for fp-elf*.d
anymore. All targets ought to now conform to fp.d.

Jan
Alan Modra via Binutils Aug. 17, 2021, 12:37 p.m. | #8
On Tue, Aug 17, 2021 at 12:49 AM Jan Beulich <jbeulich@suse.com> wrote:
>

> On 16.08.2021 15:40, H.J. Lu wrote:

> > On Sun, Aug 15, 2021 at 11:48 PM Jan Beulich <jbeulich@suse.com> wrote:

> >>

> >> On 15.08.2021 22:34, H.J. Lu wrote:

> >>> .tfloat output should always be 10 bytes without padding, independent

> >>> of psABIs.

> >>

> >> I disagree. It's been a long standing bug. I can see that affecting

> >> existing code isn't nice, so I could see us emit e.g. a warning for

> >> the time being. In the worst case we might add a command line option

> >> to drive the behavior.

> >>

> >>>  In glibc, x86 assembly codes expect 10-byte .tfloat output.

> >>> This also changes .ds.x output and .tfloat output with hex input to

> >>> match .tfloat output.

> >>

> >> This leaves users without any ABI-conforming way to produce double

> >> extended precision values, short of hand-coding the padding. Even if

> >> you were really going to insist that retaining the broken behavior

> >> of .tfloat is necessary, a directive providing correct behavior

> >> should be available. This might then be .d{c,cb,s}.x, or something

> >> new. But as said - to me this really would only be a last resort.

> >> Whoever introduced .tfloat in its present way screwed up, and

> >> whoever forgot to fix .tfloat for x86-64 didn't even pay attention

> >> to the ABI difference.

> >>

> >>>       PR gas/28230

> >>>       * config/tc-i386.c (x86_tfloat_pad): Removed.

> >>>       * config/tc-i386.h (X_PRECISION_PAD): Changed to 0.

> >>>       (x86_tfloat_pad): Removed.

> >>>       * testsuite/gas/i386/fp.s: If NO_TFLOAT_PADDING isn't defined,

> >>>       add explicit paddings after .tfloat, .ds.x, .dc.x and .dcb.x

> >>>       directives.

> >>>       * testsuite/gas/i386/i386.exp (ASFLAGS): Append

> >>>       "--defsym NO_TFLOAT_PADDING=1" when running the fp test.

> >>

> >> I'm afraid I don't understand the games you play here: If you

> >> really thought .tfloat should not emit ABI-conforming data, then

> >> why would you bother introducing NO_TFLOAT_PADDING to allow for

> >> alternative behavior?

> >

> > Since I don't want to change fp-elf32.d nor fp-elf64.d, I added paddings

> > manually.  fp.d doesn't expect paddings.

>

> But with .tfloat no longer honoring ABI there's no need for fp-elf*.d

> anymore. All targets ought to now conform to fp.d.

>


I am checking in this patch.

-- 
H.J.
From faca1a42d3f5fd123945a367d190cac15926b15c Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Tue, 17 Aug 2021 05:28:30 -0700
Subject: [PATCH] x86: Always run fp tests

Always run fp tests since the size of .tfloat, .ds.x, .dc.x and .dcb.x
directive outputs is always 10 bytes.  There is no need for fp-elf32 nor
fp-elf64.

	PR gas/28230
	* testsuite/gas/i386/fp-elf32.d: Removed.
	* testsuite/gas/i386/fp-elf64.d: Likewise.
	* testsuite/gas/i386/fp.s: Remove NO_TFLOAT_PADDING codes.
	* testsuite/gas/i386/i386.exp: Don't run fp-elf32 nor fp-elf64.
	Always run fp.
---
 gas/testsuite/gas/i386/fp-elf32.d |  41 ----------
 gas/testsuite/gas/i386/fp-elf64.d |  41 ----------
 gas/testsuite/gas/i386/fp.s       | 119 ------------------------------
 gas/testsuite/gas/i386/i386.exp   |   8 +-
 4 files changed, 1 insertion(+), 208 deletions(-)
 delete mode 100644 gas/testsuite/gas/i386/fp-elf32.d
 delete mode 100644 gas/testsuite/gas/i386/fp-elf64.d

diff --git a/gas/testsuite/gas/i386/fp-elf32.d b/gas/testsuite/gas/i386/fp-elf32.d
deleted file mode 100644
index ac67c2ae721..00000000000
--- a/gas/testsuite/gas/i386/fp-elf32.d
+++ /dev/null
@@ -1,41 +0,0 @@
-#objdump: -s -j .data
-#name: i386 fp (ELF)
-#source: fp.s
-
-.*:     file format .*
-
-Contents of section .data:
- 0000 00881bcd 4b789ad4 00400000 71a37909  .*
- 0010 4f930a40 789a5440 789a5440 00000000  .*
- 0020 e65e1710 20395e3b e65e1710 20395e3b  .*
- 0030 00000000 0000a044 01000000 0000a044  .*
- 0040 00000000 0000f03f 00000000 00000000  .*
- 0050 ffffffff ffffffff ffffffff cccccccc  .*
- 0060 00000000 00000080 fe3f0000 00000000  .*
- 0070 00000080 fdbf0000 00000000 00000080  .*
- 0080 ff030000 aaaaaaaa aaaaaaaa aaaaaaaa  .*
- 0090 003c00c0 003c803f 00c0803f 55555555  .*
- 00a0 007c807f 0000807f 00000000 0000f07f  .*
- 00b0 00000000 00000080 ff7f0000 44444444  .*
- 00c0 007c807f 0000807f 00000000 0000f07f  .*
- 00d0 00000000 00000080 ff7f0000 33333333  .*
- 00e0 00fc80ff 000080ff 00000000 0000f0ff  .*
- 00f0 00000000 00000080 ffff0000 22222222  .*
- 0100 ff7fff7f ffffff7f ffffffff ffffff7f  .*
- 0110 ffffffff ffffffff ff7f0000 44444444  .*
- 0120 ff7fff7f ffffff7f ffffffff ffffff7f  .*
- 0130 ffffffff ffffffff ff7f0000 33333333  .*
- 0140 ffffffff ffffffff ffffffff ffffffff  .*
- 0150 ffffffff ffffffff ffff0000 22222222  .*
- 0160 ff7fff7f ffffff7f ffffffff ffffff7f  .*
- 0170 ffffffff ffffffff ff7f0000 44444444  .*
- 0180 ff7fff7f ffffff7f ffffffff ffffff7f  .*
- 0190 ffffffff ffffffff ff7f0000 33333333  .*
- 01a0 ffffffff ffffffff ffffffff ffffffff  .*
- 01b0 ffffffff ffffffff ffff0000 22222222  .*
- 01c0 ff7dbf7f ffffbf7f ffffffff fffff77f  .*
- 01d0 ffffffff ffffffbf ff7f0000 44444444  .*
- 01e0 ff7dbf7f ffffbf7f ffffffff fffff77f  .*
- 01f0 ffffffff ffffffbf ff7f0000 33333333  .*
- 0200 fffdbfff ffffbfff ffffffff fffff7ff  .*
- 0210 ffffffff ffffffbf ffff0000 22222222  .*
diff --git a/gas/testsuite/gas/i386/fp-elf64.d b/gas/testsuite/gas/i386/fp-elf64.d
deleted file mode 100644
index 2b3b6b8b29a..00000000000
--- a/gas/testsuite/gas/i386/fp-elf64.d
+++ /dev/null
@@ -1,41 +0,0 @@
-#objdump: -s -j .data
-#name: x86-64 fp (ELF)
-#source: fp.s
-
-.*:     file format .*
-
-Contents of section .data:
- 0000 00881bcd 4b789ad4 00400000 00000000  .*
- 0010 71a37909 4f930a40 789a5440 789a5440  .*
- 0020 e65e1710 20395e3b e65e1710 20395e3b  .*
- 0030 00000000 0000a044 01000000 0000a044  .*
- 0040 00000000 0000f03f 00000000 00000000  .*
- 0050 ffffffff ffffffff ffffffff ffffffff  .*
- 0060 00000000 00000080 fe3f0000 00000000  .*
- 0070 00000000 00000080 fdbf0000 00000000  .*
- 0080 00000000 00000080 ff030000 00000000  .*
- 0090 003c00c0 003c803f 00c0803f 55555555  .*
- 00a0 007c807f 0000807f 00000000 0000f07f  .*
- 00b0 00000000 00000080 ff7f0000 00000000  .*
- 00c0 007c807f 0000807f 00000000 0000f07f  .*
- 00d0 00000000 00000080 ff7f0000 00000000  .*
- 00e0 00fc80ff 000080ff 00000000 0000f0ff  .*
- 00f0 00000000 00000080 ffff0000 00000000  .*
- 0100 ff7fff7f ffffff7f ffffffff ffffff7f  .*
- 0110 ffffffff ffffffff ff7f0000 00000000  .*
- 0120 ff7fff7f ffffff7f ffffffff ffffff7f  .*
- 0130 ffffffff ffffffff ff7f0000 00000000  .*
- 0140 ffffffff ffffffff ffffffff ffffffff  .*
- 0150 ffffffff ffffffff ffff0000 00000000  .*
- 0160 ff7fff7f ffffff7f ffffffff ffffff7f  .*
- 0170 ffffffff ffffffff ff7f0000 00000000  .*
- 0180 ff7fff7f ffffff7f ffffffff ffffff7f  .*
- 0190 ffffffff ffffffff ff7f0000 00000000  .*
- 01a0 ffffffff ffffffff ffffffff ffffffff  .*
- 01b0 ffffffff ffffffff ffff0000 00000000  .*
- 01c0 ff7dbf7f ffffbf7f ffffffff fffff77f  .*
- 01d0 ffffffff ffffffbf ff7f0000 00000000  .*
- 01e0 ff7dbf7f ffffbf7f ffffffff fffff77f  .*
- 01f0 ffffffff ffffffbf ff7f0000 00000000  .*
- 0200 fffdbfff ffffbfff ffffffff fffff7ff  .*
- 0210 ffffffff ffffffbf ffff0000 00000000  .*
diff --git a/gas/testsuite/gas/i386/fp.s b/gas/testsuite/gas/i386/fp.s
index 90854b740ad..a63464b6cd2 100644
--- a/gas/testsuite/gas/i386/fp.s
+++ b/gas/testsuite/gas/i386/fp.s
@@ -1,13 +1,6 @@
 	.data
 # .tfloat is 80-bit floating point format.
 	.tfloat 3.32192809488736218171e0
-.ifndef NO_TFLOAT_PADDING
-  .ifdef x86_64
-	.byte 0, 0, 0, 0, 0, 0
-  .else
-	.byte 0, 0
-  .endif
-.endif
 #	.byte 0x0, 0x88, 0x1b, 0xcd, 0x4b, 0x78, 0x9a, 0xd4, 0x0, 0x40
 # .double is 64-bit floating point format.
 	.double 3.32192809488736218171e0
@@ -30,39 +23,11 @@
 	.p2align 4,0
 
 	.ds.x 1, -1
-.ifndef NO_TFLOAT_PADDING
-  .ifdef x86_64
-	.byte -1, -1, -1, -1, -1, -1
-  .else
-	.byte -1, -1
-  .endif
-.endif
 	.p2align 4,0xcc
 
 	.tfloat 0x:3ffe80
-.ifndef NO_TFLOAT_PADDING
-  .ifdef x86_64
-	.byte 0, 0, 0, 0, 0, 0
-  .else
-	.byte 0, 0
-  .endif
-.endif
 	.dc.x 0x:bffd80
-.ifndef NO_TFLOAT_PADDING
-  .ifdef x86_64
-	.byte 0, 0, 0, 0, 0, 0
-  .else
-	.byte 0, 0
-  .endif
-.endif
 	.dcb.x 1, 0x:03ff80
-.ifndef NO_TFLOAT_PADDING
-  .ifdef x86_64
-	.byte 0, 0, 0, 0, 0, 0
-  .else
-	.byte 0, 0
-  .endif
-.endif
 	.p2align 4,0xaa
 
 	.hfloat 1, -2, 0x:3c00
@@ -74,13 +39,6 @@
 	.single Inf
 	.double Inf
 	.tfloat Inf
-.ifndef NO_TFLOAT_PADDING
-  .ifdef x86_64
-	.byte 0, 0, 0, 0, 0, 0
-  .else
-	.byte 0, 0
-  .endif
-.endif
 	.p2align 4,0x44
 
 	.hfloat +Inf
@@ -88,13 +46,6 @@
 	.single +Inf
 	.double +Inf
 	.tfloat +Inf
-.ifndef NO_TFLOAT_PADDING
-  .ifdef x86_64
-	.byte 0, 0, 0, 0, 0, 0
-  .else
-	.byte 0, 0
-  .endif
-.endif
 	.p2align 4,0x33
 
 	.hfloat -Inf
@@ -102,13 +53,6 @@
 	.single -Inf
 	.double -Inf
 	.tfloat -Inf
-.ifndef NO_TFLOAT_PADDING
-  .ifdef x86_64
-	.byte 0, 0, 0, 0, 0, 0
-  .else
-	.byte 0, 0
-  .endif
-.endif
 	.p2align 4,0x22
 
 	.hfloat NaN
@@ -116,13 +60,6 @@
 	.single NaN
 	.double NaN
 	.tfloat NaN
-.ifndef NO_TFLOAT_PADDING
-  .ifdef x86_64
-	.byte 0, 0, 0, 0, 0, 0
-  .else
-	.byte 0, 0
-  .endif
-.endif
 	.p2align 4,0x44
 
 	.hfloat +NaN
@@ -130,13 +67,6 @@
 	.single +NaN
 	.double +NaN
 	.tfloat +NaN
-.ifndef NO_TFLOAT_PADDING
-  .ifdef x86_64
-	.byte 0, 0, 0, 0, 0, 0
-  .else
-	.byte 0, 0
-  .endif
-.endif
 	.p2align 4,0x33
 
 	.hfloat -NaN
@@ -144,13 +74,6 @@
 	.single -NaN
 	.double -NaN
 	.tfloat -NaN
-.ifndef NO_TFLOAT_PADDING
-  .ifdef x86_64
-	.byte 0, 0, 0, 0, 0, 0
-  .else
-	.byte 0, 0
-  .endif
-.endif
 	.p2align 4,0x22
 
 	.hfloat QNaN
@@ -158,13 +81,6 @@
 	.single QNaN
 	.double QNaN
 	.tfloat QNaN
-.ifndef NO_TFLOAT_PADDING
-  .ifdef x86_64
-	.byte 0, 0, 0, 0, 0, 0
-  .else
-	.byte 0, 0
-  .endif
-.endif
 	.p2align 4,0x44
 
 	.hfloat +QNaN
@@ -172,13 +88,6 @@
 	.single +QNaN
 	.double +QNaN
 	.tfloat +QNaN
-.ifndef NO_TFLOAT_PADDING
-  .ifdef x86_64
-	.byte 0, 0, 0, 0, 0, 0
-  .else
-	.byte 0, 0
-  .endif
-.endif
 	.p2align 4,0x33
 
 	.hfloat -QNaN
@@ -186,13 +95,6 @@
 	.single -QNaN
 	.double -QNaN
 	.tfloat -QNaN
-.ifndef NO_TFLOAT_PADDING
-  .ifdef x86_64
-	.byte 0, 0, 0, 0, 0, 0
-  .else
-	.byte 0, 0
-  .endif
-.endif
 	.p2align 4,0x22
 
 	.hfloat SNaN
@@ -200,13 +102,6 @@
 	.single SNaN
 	.double SNaN
 	.tfloat SNaN
-.ifndef NO_TFLOAT_PADDING
-  .ifdef x86_64
-	.byte 0, 0, 0, 0, 0, 0
-  .else
-	.byte 0, 0
-  .endif
-.endif
 	.p2align 4,0x44
 
 	.hfloat +SNaN
@@ -214,13 +109,6 @@
 	.single +SNaN
 	.double +SNaN
 	.tfloat +SNaN
-.ifndef NO_TFLOAT_PADDING
-  .ifdef x86_64
-	.byte 0, 0, 0, 0, 0, 0
-  .else
-	.byte 0, 0
-  .endif
-.endif
 	.p2align 4,0x33
 
 	.hfloat -SNaN
@@ -228,11 +116,4 @@
 	.single -SNaN
 	.double -SNaN
 	.tfloat -SNaN
-.ifndef NO_TFLOAT_PADDING
-  .ifdef x86_64
-	.byte 0, 0, 0, 0, 0, 0
-  .else
-	.byte 0, 0
-  .endif
-.endif
 	.p2align 4,0x22
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index 189121f1428..f5eda2cf331 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -623,7 +623,6 @@ if [gas_32_check] then {
 	run_dump_test "intel-movs16"
 	run_dump_test "intel-cmps32"
 	run_dump_test "intel-cmps16"
-	run_dump_test "fp-elf32"
 	run_list_test "inval-equ-1" "-al"
 	run_list_test "inval-equ-2" "-al"
 	run_dump_test "ifunc"
@@ -697,11 +696,6 @@ if [gas_32_check] then {
 	    run_dump_test "iamcu-5"
 	    run_list_test "iamcu-inval-1" "-march=iamcu -al"
 	}
-    } else {
-	set saved_ASFLAGS "$ASFLAGS"
-	append ASFLAGS " --defsym NO_TFLOAT_PADDING=1"
-	run_dump_test "fp"
-	set $ASFLAGS "$saved_ASFLAGS"
     }
 
     # This is a PE specific test.
@@ -730,6 +724,7 @@ run_dump_test rept
 run_dump_test pr19498
 run_list_test "nop-bad-1" ""
 run_list_test "unspec" ""
+run_dump_test "fp"
 if {[is_elf_format] || [istarget "*-*-vxworks*"]} then {
     run_list_test_stdin "list-1" "-al"
     run_list_test_stdin "list-2" "-al"
@@ -1279,7 +1274,6 @@ if [gas_64_check] then {
 	run_list_test "reloc64" "--defsym _bad_=1"
 	run_dump_test "mixed-mode-reloc64"
 	run_dump_test "rela"
-	run_dump_test "fp-elf64"
 	run_dump_test "x86-64-ifunc"
 	run_dump_test "x86-64-opcode-inval"
 	run_dump_test "x86-64-opcode-inval-intel"

Patch

diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index dc29fa2ba52..7148c073247 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -10231,19 +10231,6 @@  x86_cons_fix_new (fragS *frag, unsigned int off, unsigned int len,
   fix_new_exp (frag, off, len, exp, 0, r);
 }
 
-/* Return the number of padding LITTLENUMs following a tbyte floating
-   point value.  */
-
-int
-x86_tfloat_pad (void)
-{
-#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
-   if (IS_ELF)
-     return object_64bit ? 3 : 1;
-#endif
-   return 0;
-}
-
 /* Export the ABI address size for use by TC_ADDRESS_BYTES for the
    purpose of the `.dc.a' internal pseudo-op.  */
 
diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h
index 2dc6312f28e..f50169cbcc0 100644
--- a/gas/config/tc-i386.h
+++ b/gas/config/tc-i386.h
@@ -135,8 +135,7 @@  extern void x86_cons_fix_new
 (fragS *, unsigned int, unsigned int, expressionS *, bfd_reloc_code_real_type);
 
 #define X_PRECISION     5
-#define X_PRECISION_PAD x86_tfloat_pad ()
-extern int x86_tfloat_pad (void);
+#define X_PRECISION_PAD 0
 
 #define TC_ADDRESS_BYTES x86_address_bytes
 extern int x86_address_bytes (void);
diff --git a/gas/testsuite/gas/i386/fp.s b/gas/testsuite/gas/i386/fp.s
index a63464b6cd2..90854b740ad 100644
--- a/gas/testsuite/gas/i386/fp.s
+++ b/gas/testsuite/gas/i386/fp.s
@@ -1,6 +1,13 @@ 
 	.data
 # .tfloat is 80-bit floating point format.
 	.tfloat 3.32192809488736218171e0
+.ifndef NO_TFLOAT_PADDING
+  .ifdef x86_64
+	.byte 0, 0, 0, 0, 0, 0
+  .else
+	.byte 0, 0
+  .endif
+.endif
 #	.byte 0x0, 0x88, 0x1b, 0xcd, 0x4b, 0x78, 0x9a, 0xd4, 0x0, 0x40
 # .double is 64-bit floating point format.
 	.double 3.32192809488736218171e0
@@ -23,11 +30,39 @@ 
 	.p2align 4,0
 
 	.ds.x 1, -1
+.ifndef NO_TFLOAT_PADDING
+  .ifdef x86_64
+	.byte -1, -1, -1, -1, -1, -1
+  .else
+	.byte -1, -1
+  .endif
+.endif
 	.p2align 4,0xcc
 
 	.tfloat 0x:3ffe80
+.ifndef NO_TFLOAT_PADDING
+  .ifdef x86_64
+	.byte 0, 0, 0, 0, 0, 0
+  .else
+	.byte 0, 0
+  .endif
+.endif
 	.dc.x 0x:bffd80
+.ifndef NO_TFLOAT_PADDING
+  .ifdef x86_64
+	.byte 0, 0, 0, 0, 0, 0
+  .else
+	.byte 0, 0
+  .endif
+.endif
 	.dcb.x 1, 0x:03ff80
+.ifndef NO_TFLOAT_PADDING
+  .ifdef x86_64
+	.byte 0, 0, 0, 0, 0, 0
+  .else
+	.byte 0, 0
+  .endif
+.endif
 	.p2align 4,0xaa
 
 	.hfloat 1, -2, 0x:3c00
@@ -39,6 +74,13 @@ 
 	.single Inf
 	.double Inf
 	.tfloat Inf
+.ifndef NO_TFLOAT_PADDING
+  .ifdef x86_64
+	.byte 0, 0, 0, 0, 0, 0
+  .else
+	.byte 0, 0
+  .endif
+.endif
 	.p2align 4,0x44
 
 	.hfloat +Inf
@@ -46,6 +88,13 @@ 
 	.single +Inf
 	.double +Inf
 	.tfloat +Inf
+.ifndef NO_TFLOAT_PADDING
+  .ifdef x86_64
+	.byte 0, 0, 0, 0, 0, 0
+  .else
+	.byte 0, 0
+  .endif
+.endif
 	.p2align 4,0x33
 
 	.hfloat -Inf
@@ -53,6 +102,13 @@ 
 	.single -Inf
 	.double -Inf
 	.tfloat -Inf
+.ifndef NO_TFLOAT_PADDING
+  .ifdef x86_64
+	.byte 0, 0, 0, 0, 0, 0
+  .else
+	.byte 0, 0
+  .endif
+.endif
 	.p2align 4,0x22
 
 	.hfloat NaN
@@ -60,6 +116,13 @@ 
 	.single NaN
 	.double NaN
 	.tfloat NaN
+.ifndef NO_TFLOAT_PADDING
+  .ifdef x86_64
+	.byte 0, 0, 0, 0, 0, 0
+  .else
+	.byte 0, 0
+  .endif
+.endif
 	.p2align 4,0x44
 
 	.hfloat +NaN
@@ -67,6 +130,13 @@ 
 	.single +NaN
 	.double +NaN
 	.tfloat +NaN
+.ifndef NO_TFLOAT_PADDING
+  .ifdef x86_64
+	.byte 0, 0, 0, 0, 0, 0
+  .else
+	.byte 0, 0
+  .endif
+.endif
 	.p2align 4,0x33
 
 	.hfloat -NaN
@@ -74,6 +144,13 @@ 
 	.single -NaN
 	.double -NaN
 	.tfloat -NaN
+.ifndef NO_TFLOAT_PADDING
+  .ifdef x86_64
+	.byte 0, 0, 0, 0, 0, 0
+  .else
+	.byte 0, 0
+  .endif
+.endif
 	.p2align 4,0x22
 
 	.hfloat QNaN
@@ -81,6 +158,13 @@ 
 	.single QNaN
 	.double QNaN
 	.tfloat QNaN
+.ifndef NO_TFLOAT_PADDING
+  .ifdef x86_64
+	.byte 0, 0, 0, 0, 0, 0
+  .else
+	.byte 0, 0
+  .endif
+.endif
 	.p2align 4,0x44
 
 	.hfloat +QNaN
@@ -88,6 +172,13 @@ 
 	.single +QNaN
 	.double +QNaN
 	.tfloat +QNaN
+.ifndef NO_TFLOAT_PADDING
+  .ifdef x86_64
+	.byte 0, 0, 0, 0, 0, 0
+  .else
+	.byte 0, 0
+  .endif
+.endif
 	.p2align 4,0x33
 
 	.hfloat -QNaN
@@ -95,6 +186,13 @@ 
 	.single -QNaN
 	.double -QNaN
 	.tfloat -QNaN
+.ifndef NO_TFLOAT_PADDING
+  .ifdef x86_64
+	.byte 0, 0, 0, 0, 0, 0
+  .else
+	.byte 0, 0
+  .endif
+.endif
 	.p2align 4,0x22
 
 	.hfloat SNaN
@@ -102,6 +200,13 @@ 
 	.single SNaN
 	.double SNaN
 	.tfloat SNaN
+.ifndef NO_TFLOAT_PADDING
+  .ifdef x86_64
+	.byte 0, 0, 0, 0, 0, 0
+  .else
+	.byte 0, 0
+  .endif
+.endif
 	.p2align 4,0x44
 
 	.hfloat +SNaN
@@ -109,6 +214,13 @@ 
 	.single +SNaN
 	.double +SNaN
 	.tfloat +SNaN
+.ifndef NO_TFLOAT_PADDING
+  .ifdef x86_64
+	.byte 0, 0, 0, 0, 0, 0
+  .else
+	.byte 0, 0
+  .endif
+.endif
 	.p2align 4,0x33
 
 	.hfloat -SNaN
@@ -116,4 +228,11 @@ 
 	.single -SNaN
 	.double -SNaN
 	.tfloat -SNaN
+.ifndef NO_TFLOAT_PADDING
+  .ifdef x86_64
+	.byte 0, 0, 0, 0, 0, 0
+  .else
+	.byte 0, 0
+  .endif
+.endif
 	.p2align 4,0x22
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index 122da6a2315..189121f1428 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -698,7 +698,10 @@  if [gas_32_check] then {
 	    run_list_test "iamcu-inval-1" "-march=iamcu -al"
 	}
     } else {
+	set saved_ASFLAGS "$ASFLAGS"
+	append ASFLAGS " --defsym NO_TFLOAT_PADDING=1"
 	run_dump_test "fp"
+	set $ASFLAGS "$saved_ASFLAGS"
     }
 
     # This is a PE specific test.