* [Qemu-devel] [Bug 1728325] [NEW] POWER8: Wrong behaviour with float-to-int punning
@ 2017-10-29 1:10 Iain Buclaw
2017-10-29 1:15 ` [Qemu-devel] [Bug 1728325] " Iain Buclaw
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Iain Buclaw @ 2017-10-29 1:10 UTC (permalink / raw)
To: qemu-devel
Public bug reported:
Building a reduced test program with 'gcc -O2 -fno-inline -mcpu=power8'
produces wrong results at runtime. I don't think gcc is at fault here.
---
#include <stdio.h>
int getWord(const float x)
{
return *(int*)&x;
}
void main()
{
int foo = getWord(+123.456f);
int bar = getWord(-123.456f);
printf("%d\n", foo);
printf("%d\n", bar);
return;
}
---
This prints:
---
0
0
---
Compiling with 'gcc -O2 -fno-inline -mcpu=power7' and you instead get the expected result:
---
1123477881
-1024005767
---
The different between the two programs is:
--- power7.s
+++ power8.s
@@ -6,9 +6,9 @@
.globl getWord
.type getWord, @function
getWord:
- stfs 1,-16(1)
- ori 2,2,0
- lwa 3,-16(1)
+ xscvdpspn 0,1
+ mfvsrwz 3,0
+ extsw 3,3
blr
.long 0
.byte 0,0,0,0,0,0,0,0
.size getWord,.-getWord
Seems like qemu doesn't handle xscvdpspn/mfvsrwz correctly.
https://github.com/qemu/qemu/commit/7ee19fb9d682689d36c849576c808cf92e3bae40
https://github.com/qemu/qemu/commit/f5c0f7f981333da59cc35c3210d05ec1775c97c1
** Affects: qemu
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1728325
Title:
POWER8: Wrong behaviour with float-to-int punning
Status in QEMU:
New
Bug description:
Building a reduced test program with 'gcc -O2 -fno-inline
-mcpu=power8' produces wrong results at runtime. I don't think gcc is
at fault here.
---
#include <stdio.h>
int getWord(const float x)
{
return *(int*)&x;
}
void main()
{
int foo = getWord(+123.456f);
int bar = getWord(-123.456f);
printf("%d\n", foo);
printf("%d\n", bar);
return;
}
---
This prints:
---
0
0
---
Compiling with 'gcc -O2 -fno-inline -mcpu=power7' and you instead get the expected result:
---
1123477881
-1024005767
---
The different between the two programs is:
--- power7.s
+++ power8.s
@@ -6,9 +6,9 @@
.globl getWord
.type getWord, @function
getWord:
- stfs 1,-16(1)
- ori 2,2,0
- lwa 3,-16(1)
+ xscvdpspn 0,1
+ mfvsrwz 3,0
+ extsw 3,3
blr
.long 0
.byte 0,0,0,0,0,0,0,0
.size getWord,.-getWord
Seems like qemu doesn't handle xscvdpspn/mfvsrwz correctly.
https://github.com/qemu/qemu/commit/7ee19fb9d682689d36c849576c808cf92e3bae40
https://github.com/qemu/qemu/commit/f5c0f7f981333da59cc35c3210d05ec1775c97c1
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1728325/+subscriptions
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [Bug 1728325] Re: POWER8: Wrong behaviour with float-to-int punning
2017-10-29 1:10 [Qemu-devel] [Bug 1728325] [NEW] POWER8: Wrong behaviour with float-to-int punning Iain Buclaw
@ 2017-10-29 1:15 ` Iain Buclaw
2017-10-31 9:35 ` Richard Henderson
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Iain Buclaw @ 2017-10-29 1:15 UTC (permalink / raw)
To: qemu-devel
I am running:
qemu-ppc64le-static -L /usr/powerpc64le-linux-gnu ./a.out
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1728325
Title:
POWER8: Wrong behaviour with float-to-int punning
Status in QEMU:
New
Bug description:
Building a reduced test program with 'gcc -O2 -fno-inline
-mcpu=power8' produces wrong results at runtime. I don't think gcc is
at fault here.
---
#include <stdio.h>
int getWord(const float x)
{
return *(int*)&x;
}
void main()
{
int foo = getWord(+123.456f);
int bar = getWord(-123.456f);
printf("%d\n", foo);
printf("%d\n", bar);
return;
}
---
This prints:
---
0
0
---
Compiling with 'gcc -O2 -fno-inline -mcpu=power7' and you instead get the expected result:
---
1123477881
-1024005767
---
The different between the two programs is:
--- power7.s
+++ power8.s
@@ -6,9 +6,9 @@
.globl getWord
.type getWord, @function
getWord:
- stfs 1,-16(1)
- ori 2,2,0
- lwa 3,-16(1)
+ xscvdpspn 0,1
+ mfvsrwz 3,0
+ extsw 3,3
blr
.long 0
.byte 0,0,0,0,0,0,0,0
.size getWord,.-getWord
Seems like qemu doesn't handle xscvdpspn/mfvsrwz correctly.
https://github.com/qemu/qemu/commit/7ee19fb9d682689d36c849576c808cf92e3bae40
https://github.com/qemu/qemu/commit/f5c0f7f981333da59cc35c3210d05ec1775c97c1
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1728325/+subscriptions
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [Bug 1728325] Re: POWER8: Wrong behaviour with float-to-int punning
2017-10-29 1:10 [Qemu-devel] [Bug 1728325] [NEW] POWER8: Wrong behaviour with float-to-int punning Iain Buclaw
2017-10-29 1:15 ` [Qemu-devel] [Bug 1728325] " Iain Buclaw
@ 2017-10-31 9:35 ` Richard Henderson
2017-10-31 10:38 ` Iain Buclaw
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2017-10-31 9:35 UTC (permalink / raw)
To: qemu-devel
This is buggy C.
https://gcc.gnu.org/bugs/#nonbugs_c
** Changed in: qemu
Status: New => Invalid
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1728325
Title:
POWER8: Wrong behaviour with float-to-int punning
Status in QEMU:
Invalid
Bug description:
Building a reduced test program with 'gcc -O2 -fno-inline
-mcpu=power8' produces wrong results at runtime. I don't think gcc is
at fault here.
---
#include <stdio.h>
int getWord(const float x)
{
return *(int*)&x;
}
void main()
{
int foo = getWord(+123.456f);
int bar = getWord(-123.456f);
printf("%d\n", foo);
printf("%d\n", bar);
return;
}
---
This prints:
---
0
0
---
Compiling with 'gcc -O2 -fno-inline -mcpu=power7' and you instead get the expected result:
---
1123477881
-1024005767
---
The different between the two programs is:
--- power7.s
+++ power8.s
@@ -6,9 +6,9 @@
.globl getWord
.type getWord, @function
getWord:
- stfs 1,-16(1)
- ori 2,2,0
- lwa 3,-16(1)
+ xscvdpspn 0,1
+ mfvsrwz 3,0
+ extsw 3,3
blr
.long 0
.byte 0,0,0,0,0,0,0,0
.size getWord,.-getWord
Seems like qemu doesn't handle xscvdpspn/mfvsrwz correctly.
https://github.com/qemu/qemu/commit/7ee19fb9d682689d36c849576c808cf92e3bae40
https://github.com/qemu/qemu/commit/f5c0f7f981333da59cc35c3210d05ec1775c97c1
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1728325/+subscriptions
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [Bug 1728325] Re: POWER8: Wrong behaviour with float-to-int punning
2017-10-29 1:10 [Qemu-devel] [Bug 1728325] [NEW] POWER8: Wrong behaviour with float-to-int punning Iain Buclaw
2017-10-29 1:15 ` [Qemu-devel] [Bug 1728325] " Iain Buclaw
2017-10-31 9:35 ` Richard Henderson
@ 2017-10-31 10:38 ` Iain Buclaw
2020-11-10 3:11 ` Thomas Huth
2021-01-09 4:17 ` Launchpad Bug Tracker
4 siblings, 0 replies; 6+ messages in thread
From: Iain Buclaw @ 2017-10-31 10:38 UTC (permalink / raw)
To: qemu-devel
The original code used a union. It generates the same assembler all the
same.
** Changed in: qemu
Status: Invalid => New
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1728325
Title:
POWER8: Wrong behaviour with float-to-int punning
Status in QEMU:
New
Bug description:
Building a reduced test program with 'gcc -O2 -fno-inline
-mcpu=power8' produces wrong results at runtime. I don't think gcc is
at fault here.
---
#include <stdio.h>
int getWord(const float x)
{
return *(int*)&x;
}
void main()
{
int foo = getWord(+123.456f);
int bar = getWord(-123.456f);
printf("%d\n", foo);
printf("%d\n", bar);
return;
}
---
This prints:
---
0
0
---
Compiling with 'gcc -O2 -fno-inline -mcpu=power7' and you instead get the expected result:
---
1123477881
-1024005767
---
The different between the two programs is:
--- power7.s
+++ power8.s
@@ -6,9 +6,9 @@
.globl getWord
.type getWord, @function
getWord:
- stfs 1,-16(1)
- ori 2,2,0
- lwa 3,-16(1)
+ xscvdpspn 0,1
+ mfvsrwz 3,0
+ extsw 3,3
blr
.long 0
.byte 0,0,0,0,0,0,0,0
.size getWord,.-getWord
Seems like qemu doesn't handle xscvdpspn/mfvsrwz correctly.
https://github.com/qemu/qemu/commit/7ee19fb9d682689d36c849576c808cf92e3bae40
https://github.com/qemu/qemu/commit/f5c0f7f981333da59cc35c3210d05ec1775c97c1
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1728325/+subscriptions
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug 1728325] Re: POWER8: Wrong behaviour with float-to-int punning
2017-10-29 1:10 [Qemu-devel] [Bug 1728325] [NEW] POWER8: Wrong behaviour with float-to-int punning Iain Buclaw
` (2 preceding siblings ...)
2017-10-31 10:38 ` Iain Buclaw
@ 2020-11-10 3:11 ` Thomas Huth
2021-01-09 4:17 ` Launchpad Bug Tracker
4 siblings, 0 replies; 6+ messages in thread
From: Thomas Huth @ 2020-11-10 3:11 UTC (permalink / raw)
To: qemu-devel
The QEMU project is currently considering to move its bug tracking to another system. For this we need to know which bugs are still valid and which could be closed already. Thus we are setting older bugs to "Incomplete" now.
If you still think this bug report here is valid, then please switch the state back to "New" within the next 60 days, otherwise this report will be marked as "Expired". Or mark it as "Fix Released" if the problem has been solved with a newer version of QEMU already. Thank you and sorry for the inconvenience.
** Changed in: qemu
Status: New => Incomplete
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1728325
Title:
POWER8: Wrong behaviour with float-to-int punning
Status in QEMU:
Incomplete
Bug description:
Building a reduced test program with 'gcc -O2 -fno-inline
-mcpu=power8' produces wrong results at runtime. I don't think gcc is
at fault here.
---
#include <stdio.h>
int getWord(const float x)
{
return *(int*)&x;
}
void main()
{
int foo = getWord(+123.456f);
int bar = getWord(-123.456f);
printf("%d\n", foo);
printf("%d\n", bar);
return;
}
---
This prints:
---
0
0
---
Compiling with 'gcc -O2 -fno-inline -mcpu=power7' and you instead get the expected result:
---
1123477881
-1024005767
---
The different between the two programs is:
--- power7.s
+++ power8.s
@@ -6,9 +6,9 @@
.globl getWord
.type getWord, @function
getWord:
- stfs 1,-16(1)
- ori 2,2,0
- lwa 3,-16(1)
+ xscvdpspn 0,1
+ mfvsrwz 3,0
+ extsw 3,3
blr
.long 0
.byte 0,0,0,0,0,0,0,0
.size getWord,.-getWord
Seems like qemu doesn't handle xscvdpspn/mfvsrwz correctly.
https://github.com/qemu/qemu/commit/7ee19fb9d682689d36c849576c808cf92e3bae40
https://github.com/qemu/qemu/commit/f5c0f7f981333da59cc35c3210d05ec1775c97c1
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1728325/+subscriptions
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug 1728325] Re: POWER8: Wrong behaviour with float-to-int punning
2017-10-29 1:10 [Qemu-devel] [Bug 1728325] [NEW] POWER8: Wrong behaviour with float-to-int punning Iain Buclaw
` (3 preceding siblings ...)
2020-11-10 3:11 ` Thomas Huth
@ 2021-01-09 4:17 ` Launchpad Bug Tracker
4 siblings, 0 replies; 6+ messages in thread
From: Launchpad Bug Tracker @ 2021-01-09 4:17 UTC (permalink / raw)
To: qemu-devel
[Expired for QEMU because there has been no activity for 60 days.]
** Changed in: qemu
Status: Incomplete => Expired
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1728325
Title:
POWER8: Wrong behaviour with float-to-int punning
Status in QEMU:
Expired
Bug description:
Building a reduced test program with 'gcc -O2 -fno-inline
-mcpu=power8' produces wrong results at runtime. I don't think gcc is
at fault here.
---
#include <stdio.h>
int getWord(const float x)
{
return *(int*)&x;
}
void main()
{
int foo = getWord(+123.456f);
int bar = getWord(-123.456f);
printf("%d\n", foo);
printf("%d\n", bar);
return;
}
---
This prints:
---
0
0
---
Compiling with 'gcc -O2 -fno-inline -mcpu=power7' and you instead get the expected result:
---
1123477881
-1024005767
---
The different between the two programs is:
--- power7.s
+++ power8.s
@@ -6,9 +6,9 @@
.globl getWord
.type getWord, @function
getWord:
- stfs 1,-16(1)
- ori 2,2,0
- lwa 3,-16(1)
+ xscvdpspn 0,1
+ mfvsrwz 3,0
+ extsw 3,3
blr
.long 0
.byte 0,0,0,0,0,0,0,0
.size getWord,.-getWord
Seems like qemu doesn't handle xscvdpspn/mfvsrwz correctly.
https://github.com/qemu/qemu/commit/7ee19fb9d682689d36c849576c808cf92e3bae40
https://github.com/qemu/qemu/commit/f5c0f7f981333da59cc35c3210d05ec1775c97c1
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1728325/+subscriptions
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-01-09 4:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-29 1:10 [Qemu-devel] [Bug 1728325] [NEW] POWER8: Wrong behaviour with float-to-int punning Iain Buclaw
2017-10-29 1:15 ` [Qemu-devel] [Bug 1728325] " Iain Buclaw
2017-10-31 9:35 ` Richard Henderson
2017-10-31 10:38 ` Iain Buclaw
2020-11-10 3:11 ` Thomas Huth
2021-01-09 4:17 ` Launchpad Bug Tracker
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.