plctlab / plct-qemu

PLCT实验室维护的QEMU仓库。代码放在 plct- 前缀的分支里。
http://www.qemu.org
Other
26 stars 13 forks source link

关于 flts.s指令在QEMU中的实现与HIFIVE不一致 #6

Open luyahan opened 4 years ago

luyahan commented 4 years ago

qemu: image Hifive unleashed: image

测试代码:

int main() {
  float j = -5;
  float g ;
  asm volatile(
    "fmv.d.x    fs9,x0\n"
    "flt.s   s3,%1,fs9\n"
    : "=f"(g)
    : "f"(j)
  );
}

fs9为0x0, 理论上 float=NaN. 故flt.s s3,%1,fs9 之后 s3应该为0.

refer to https://groups.google.com/a/groups.riscv.org/g/sw-dev/c/mfGw77uQYwc/m/1IrLgMpWAwAJ.

lazyparser commented 3 years ago

@liweiwei90 这个问题上游修复了么,在全家桶分支上是否fix了?

liweiwei90 commented 3 years ago

我在全家桶运行了下,也存在这个问题,我跟踪一下。

liweiwei90 commented 3 years ago

这里结果是0是合理的,fs9是由0存进去的double数据,然后用在了flt.s中,它是非nan-boxing的,所以会被用作cannonical-NAN,根据spec中的描述这里确实应该返回0:“FLT.S and FLE.S perform what the IEEE 754-2008 standard refers to as signaling comparisons: that is, they set the invalid operation exception flag if either input is NaN. FEQ.S performs a quiet comparison: it only sets the invalid operation exception flag if either input is a signaling NaN. For all three instructions, the result is 0 if either operand is NaN.”

liweiwei90 commented 3 years ago

如果是希望-5和0比较,第一条指令应该用fmv.s.x