qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [ARM - FCVT inst] : Difference in calculated value


From: Gaurav Sharma
Subject: Re: [Qemu-devel] [ARM - FCVT inst] : Difference in calculated value
Date: Fri, 22 Aug 2014 21:57:46 +0530

Great !!
As per my understanding this is because for minimum denormalized numbers we are ignoring the rounding value and returning the denormalized value which is rounded to zero.
Will have to check the behavior in case of single and double precision value functions also.

Thanks,
Gaurav


On Fri, Aug 22, 2014 at 7:58 PM, Peter Maydell <address@hidden> wrote:
On 19 August 2014 13:39, Gaurav Sharma <address@hidden> wrote:
> I am running a simple bare metal program with only the above specified
> instruction
>
> [Instrn]
> fcvt h16 s25
>
> [register values]
> SIMD register [25] = 0x9EA82A22AB98FBA8L
> FPCR = 0x40ae2f54 [with according mask removing the UFE and other
> unnecessary bit]

Thanks. My test case produced from that:

===begin===
/* aarch64-linux-gnu-gcc -g -Wall -o fcvt fcvt.c -static */
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

void do_fcvt(uint32_t fpcr, uint64_t a)
{
    uint64_t r;

    printf("a = 0x%016" PRIx64 " fpcr = 0x%08x\n", a, fpcr);

    __asm__ volatile(
        "fmov d25, %[a]\n"
        "mrs x3, FPCR\n"
        "msr FPCR, %[fpcr]\n"
        "isb\n"
        "fcvt h16, s25\n"
        "msr FPCR, x3\n"
        "isb\n"
        "fmov %[r], d16\n"
        : [r] "=r" (r)
        : [a] "r" (a),
          [fpcr] "r" (fpcr)
        : "d16", "d25", "x3"
        );

    printf("result = 0x%016" PRIx64 "\n", r);
}

int main(void)
{
    do_fcvt(0x40ae2f54 & 0x07f70000, 0x9EA82A22AB98FBA8ull);

    return 0;
}
===endit===

which on a Fast Model produces:
address@hidden:~# ./fcvt
a = 0x9ea82a22ab98fba8 fpcr = 0x00a60000
result = 0x0000000000008001

and on QEMU:
e104462:trusty:qemu$ ./build/x86/aarch64-linux-user/qemu-aarch64 /tmp/fcvt
a = 0x9ea82a22ab98fba8 fpcr = 0x40ae2f54
result = 0x0000000000008000

so we are indeed getting the rounding wrong here.

thanks
-- PMM


reply via email to

[Prev in Thread] Current Thread [Next in Thread]