[Bug target/108293] Incorrect assembly emitted for float for BPF target
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jan 5 12:43:36 GMT 2023
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.
More information about the Gcc-bugs
mailing list