Skip to content
This repository was archived by the owner on Apr 13, 2019. It is now read-only.

single float arith instructions don't produce NaN boxed output. #174

Open
jim-wilson opened this issue Oct 18, 2018 · 3 comments
Open

single float arith instructions don't produce NaN boxed output. #174

jim-wilson opened this issue Oct 18, 2018 · 3 comments

Comments

@jim-wilson
Copy link
Contributor

In translate.c, there is explicit code to NaN box the result of FLW. However, there is no equivalent code for any of the FP arithmetic instructions, add, sub, mul, div, etc. They all should produce NaN boxed results also. Likewise the conversion instructions that produce single float results. This was noticed while testing linux kernel ptrace support for FP registers in gdb running on system qemu. I can see that the raw FP values are wrong after an operation. This is probably hard to notice otherwise, you would have to have broken code that performs single float operations and then tries to read the results as double float.

(gdb)
0x0000000000010462 6 return a + b;
1: x/i $pc
=> 0x10462 <sub+22>: fadd.s fa5,fa4,fa5
(gdb) print $fa4
$1 = -nan(0xfffff3fc00000)
(gdb) print $fa5
$2 = -nan(0xfffff40200000)
(gdb) stepi
7 }
1: x/i $pc
=> 0x10466 <sub+26>: fmv.s fa0,fa5
(gdb) print $fa5
$3 = 5.3464347077054713e-315
(gdb)

info all-registers shows
fa4 -nan(0xfffff3fc00000) (raw 0xffffffff3fc00000)
fa5 5.3464347077054713e-315 (raw 0x0000000040800000)

@jim-wilson
Copy link
Contributor Author

There is a closely related bug here. If one of the input values to a single float instruction is not NaN boxed, then the result must be a canonical NaN. Qemu gets this wrong also. Found while trying to debug a different gdb bug.

@gauravdesale
Copy link

Hi is this still open im new to this project but would like to help out

@gauravdesale
Copy link

Just submitted a PR for this

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants