[Bug 264590] assembler generates wrong opcodes of instructions fdiv fdivp fdivr fdivrp fsub fsubp fsubr fsubrp

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 10 Jun 2022 09:52:31 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=264590

            Bug ID: 264590
           Summary: assembler generates wrong opcodes of instructions fdiv
                    fdivp fdivr fdivrp fsub fsubp fsubr fsubrp
           Product: Base System
           Version: 11.4-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: gnu
          Assignee: bugs@FreeBSD.org
          Reporter: var@schellong.biz

FreeBSD 11.2-RELEASE FreeBSD 11.2-RELEASE #0 r335510: Fri Jun 22 04:32:14 UTC
2018     root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64

Compiler:  clang6, gcc9, bcc32x.exe (Embarcadero, Windows)

Sample code:
--------------------------------------------
static long double sd(void)
{
   long double y;
   __asm__ ("\n\t"
            "fldpi \n\t"
            "fld1 \n\t"
            "fdivp \n\t"
            : "=t"(y)
            :
            :
            );        // st(1)=pi, st(0)=1
   return y;
}



int main(void)
{
   printf("\t%.18Lg\n", sd());
   return 0;
}
-------------------------------------------- 

Output:  0.318309886183790672 = 1/pi
But correct is:  pi = pi/1

Content of file.o:
0b+096  c4 10 5d c3 55 48 89 e5  >> d9 eb, d9 e8, de f1 << 5d c3
.                                   ^^^^^  ^^^^^  ^^^^^ 
Opcodes of 'fldpi', 'fld1' and /division/.
There is the wrong opcode 'de f1' for 'fdivrp'!
Not 'de f9' for the written 'fdivp'.
These wrong translations appear on fdivxx and fsubxx.

-- 
You are receiving this mail because:
You are the assignee for the bug.