Skip to content

RMM rounding mode doesn't work correctly #204

@spholz

Description

@spholz

The issue

This SerenityOS fenv test currently fails in RVVM, but works in QEMU:
https://github.com/SerenityOS/serenity/blob/bdfa78e487389293abc79dbb0ee9c082e8b03595/Tests/LibC/TestFenv.cpp#L81

Steps to reproduce

I made a reduced test case that prints "1" in QEMU and Spike, but "0" in RVVM:

test.s
.global _start
_start:
    fsrmi 4

    flw ft0, .LC0, t0
    flw ft1, .LC1, t0

    fadd.s ft2, ft0, ft1

    flw ft3, .LC2, t0

    feq.s t0, ft2, ft3

    bnez t0, correct

    li a0, '0'
    li a6, 2
    li a7, 0x4442434E
    ecall

1:
    wfi
    j 1b

correct:
    li a0, '1'
    li a6, 2
    li a7, 0x4442434E
    ecall

1:
    wfi
    j 1b

.LC0:
    .float 1.0
.LC1:
    .float 5.9604645e-08
.LC2:
    .float 1.0000001

You can build it using

riscv64-elf-as -march=rv64gc -o test.o test.s && riscv64-elf-ld -o test test.o && riscv64-elf-objcopy -O binary test test.bin

and then run it in RVVM with (assuming an OpenSBI build dir at $OPENSBI_BUILD)

rvvm_x86_64 $OPENSBI_BUILD/platform/generic/firmware/fw_jump.bin -k test.bin

and in QEMU with

qemu-system-riscv64 -nographic -kernel test.bin

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghelp wantedExtra attention is needed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions