public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/108293] New: Incorrect assembly emitted for float for BPF target
@ 2023-01-05 7:50 dkm at gcc dot gnu.org
2023-01-05 12:43 ` [Bug target/108293] " jakub at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: dkm at gcc dot gnu.org @ 2023-01-05 7:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108293
Bug ID: 108293
Summary: Incorrect assembly emitted for float for BPF target
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: dkm at gcc dot gnu.org
Target Milestone: ---
https://godbolt.org/z/z9WEs3Ksn
The generated code has identical function for b() and d(), which is obviously
wrong.
float f;
float a() { f = 1.0; return 1.0; }
float b() { f = 2.0; return 2.0; }
float c() { f = 2.0; return 3.0; }
float d() { f = 3.0; return 3.0; }
_Z1av:
lddw %r0,65
lddw %r1,f
stxw [%r1+0],%r0
exit
_Z1bv:
lddw %r0,129
lddw %r1,f
stxw [%r1+0],%r0
exit
_Z1cv:
lddw %r0,f
lddw %r1,129
stxw [%r0+0],%r1
lddw %r0,129
exit
_Z1dv:
lddw %r0,129
lddw %r1,f
stxw [%r1+0],%r0
exit
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/108293] Incorrect assembly emitted for float for BPF target
2023-01-05 7:50 [Bug target/108293] New: Incorrect assembly emitted for float for BPF target dkm at gcc dot gnu.org
@ 2023-01-05 12:43 ` jakub at gcc dot gnu.org
2023-01-05 12:45 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-05 12:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108293
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The bug is in bpf_print_operand:
case CONST_DOUBLE:
if (CONST_DOUBLE_HIGH (op))
fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
CONST_DOUBLE_HIGH (op), CONST_DOUBLE_LOW (op));
else if (CONST_DOUBLE_LOW (op) < 0)
fprintf (file, HOST_WIDE_INT_PRINT_HEX, CONST_DOUBLE_LOW (op));
else
fprintf (file, HOST_WIDE_INT_PRINT_DEC, CONST_DOUBLE_LOW (op));
break;
Obviously, the above handling is fine only for integral CONST_DOUBLEs, so for
floating point modes one needs to do something that other targets do, like:
else if (CONST_DOUBLE_P (x) && GET_MODE (x) == SFmode)
{
long l;
REAL_VALUE_TO_TARGET_SINGLE (*CONST_DOUBLE_REAL_VALUE (x), l);
fprintf (file, "0x%08x", (unsigned int) l);
}
for SFmode, or
else if (CONST_DOUBLE_P (x) && GET_MODE (x) == DFmode)
{
long l[2];
REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (x), l);
fprintf (file, "0x%lx%08lx", l[1] & 0xffffffff, l[0] & 0xffffffff);
}
for DFmode.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/108293] Incorrect assembly emitted for float for BPF target
2023-01-05 7:50 [Bug target/108293] New: Incorrect assembly emitted for float for BPF target dkm at gcc dot gnu.org
2023-01-05 12:43 ` [Bug target/108293] " jakub at gcc dot gnu.org
@ 2023-01-05 12:45 ` jakub at gcc dot gnu.org
2023-01-05 16:38 ` jemarch at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-05 12:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108293
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Another thing is that at least for all SFmode constant one could use mov
instead of lddw.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/108293] Incorrect assembly emitted for float for BPF target
2023-01-05 7:50 [Bug target/108293] New: Incorrect assembly emitted for float for BPF target dkm at gcc dot gnu.org
2023-01-05 12:43 ` [Bug target/108293] " jakub at gcc dot gnu.org
2023-01-05 12:45 ` jakub at gcc dot gnu.org
@ 2023-01-05 16:38 ` jemarch at gcc dot gnu.org
2023-01-06 11:15 ` marxin at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jemarch at gcc dot gnu.org @ 2023-01-05 16:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108293
--- Comment #3 from Jose E. Marchesi <jemarch at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #2)
> Another thing is that at least for all SFmode constant one could use mov
> instead of lddw.
For this I guess we could expand the "I" constraint to cover const_double that
fits in the 32-bit range. But then we would need something like IN_RANGE that
works with const_double.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/108293] Incorrect assembly emitted for float for BPF target
2023-01-05 7:50 [Bug target/108293] New: Incorrect assembly emitted for float for BPF target dkm at gcc dot gnu.org
` (2 preceding siblings ...)
2023-01-05 16:38 ` jemarch at gcc dot gnu.org
@ 2023-01-06 11:15 ` marxin at gcc dot gnu.org
2023-01-11 16:41 ` cvs-commit at gcc dot gnu.org
2023-01-11 17:24 ` jemarch at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: marxin at gcc dot gnu.org @ 2023-01-06 11:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108293
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marxin at gcc dot gnu.org
Last reconfirmed| |2023-01-06
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/108293] Incorrect assembly emitted for float for BPF target
2023-01-05 7:50 [Bug target/108293] New: Incorrect assembly emitted for float for BPF target dkm at gcc dot gnu.org
` (3 preceding siblings ...)
2023-01-06 11:15 ` marxin at gcc dot gnu.org
@ 2023-01-11 16:41 ` cvs-commit at gcc dot gnu.org
2023-01-11 17:24 ` jemarch at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-11 16:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108293
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Faust <dfaust@gcc.gnu.org>:
https://gcc.gnu.org/g:c7279270a2deda81eaeba37a87d721bee0ed6004
commit r13-5110-gc7279270a2deda81eaeba37a87d721bee0ed6004
Author: David Faust <david.faust@oracle.com>
Date: Tue Jan 10 10:53:12 2023 -0800
bpf: correct bpf_print_operand for floats [PR108293]
The existing logic in bpf_print_operand was only correct for integral
CONST_DOUBLEs, and emitted garbage for floating point modes. Fix it so
floating point mode operands are correctly handled.
PR target/108293
gcc/
* config/bpf/bpf.cc (bpf_print_operand): Correct handling for
floating point modes.
gcc/testsuite/
* gcc.target/bpf/double-1.c: New test.
* gcc.target/bpf/double-2.c: New test.
* gcc.target/bpf/float-1.c: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/108293] Incorrect assembly emitted for float for BPF target
2023-01-05 7:50 [Bug target/108293] New: Incorrect assembly emitted for float for BPF target dkm at gcc dot gnu.org
` (4 preceding siblings ...)
2023-01-11 16:41 ` cvs-commit at gcc dot gnu.org
@ 2023-01-11 17:24 ` jemarch at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jemarch at gcc dot gnu.org @ 2023-01-11 17:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108293
Jose E. Marchesi <jemarch at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #5 from Jose E. Marchesi <jemarch at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-01-11 17:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 7:50 [Bug target/108293] New: Incorrect assembly emitted for float for BPF target dkm at gcc dot gnu.org
2023-01-05 12:43 ` [Bug target/108293] " jakub at gcc dot gnu.org
2023-01-05 12:45 ` jakub at gcc dot gnu.org
2023-01-05 16:38 ` jemarch at gcc dot gnu.org
2023-01-06 11:15 ` marxin at gcc dot gnu.org
2023-01-11 16:41 ` cvs-commit at gcc dot gnu.org
2023-01-11 17:24 ` jemarch at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).