https://bugs.kde.org/show_bug.cgi?id=484426

Paul Floyd <pjfl...@wanadoo.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pjfl...@wanadoo.fr

--- Comment #1 from Paul Floyd <pjfl...@wanadoo.fr> ---
I get the same with clang++17, FreeBSD 14 on an RPi 5.

The code compiles to a call to __builtin_round

│    0x211820 <_Z5roundB7v160006f+12>                                          
                                                                               
     fcvt    d0, s0
│    0x211824 <_Z5roundB7v160006f+16>                                          
                                                                               
     frinta  d0, d0
│    0x211828 <_Z5roundB7v160006f+20>                                          
                                                                               
     fcvt    s0, d0

I think that means
convert float to double
round to int
convert double to float

Loaded into s0 I see
(gdb) p $s0
$4 = {f = 0.5, u = 1056964608, s = 1056964608}
(gdb) p /x $s0
$5 = {f = 0x3f000000, u = 0x3f000000, s = 0x3f000000}

After conversion to double
(gdb) p $d0
$8 = {f = 5.2220990168285998e-315, u = 1056964608, s = 1056964608}
(gdb) p /x $d0
$9 = {f = 0x3f000000, u = 0x3f000000, s = 0x3f000000}

Looks wrong

After the rounding
(gdb) p $d0
$10 = {f = 0, u = 0, s = 0}

And convert back to float
(gdb) p $s0
$12 = {f = 0, u = 0, s = 0}


Now, if I fix $d0 in gdb I get

(gdb) set $d0=0.5
(gdb) p $d0
$14 = {f = 0.5, u = 4602678819172646912, s = 4602678819172646912}
(gdb) p /x $d0
$15 = {f = 0x3fe0000000000000, u = 0x3fe0000000000000, s = 0x3fe0000000000000}

but that still rounds down to zero.

If I comple a double version, the __builtin_round becomes just a frinta, the
value for $d0 is the same as when I set it in gdb and it still rounds down to
0.0.

So I see two problems, the first with fcvt and the second with frinta.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to